我想执行子进程并同步它(可能与Mutex),而不等待子进程终止:
家长:
program Project1;
{$APPTYPE CONSOLE}
uses
Windows, ShellApi, SysUtils, Dialogs;
procedure ShellExecEx(Wnd: HWND; const AExeFilename, AParams: string);
const
SEE_MASK_NOZONECHECKS = $00800000;
SEE_MASK_WAITFORINPUTIDLE = $02000000;
SEE_MASK_NOASYNC = $00000100;
var
Info: TShellExecuteInfo;
begin
FillChar(Info, SizeOf(Info), 0);
Info.Wnd := Wnd;
Info.cbSize := SizeOf(Info);
Info.fMask := SEE_MASK_FLAG_NO_UI or SEE_MASK_NOZONECHECKS or
SEE_MASK_NOASYNC
//or SEE_MASK_WAITFORINPUTIDLE (works only with UI app ???)
//or SEE_MASK_NO_CONSOLE
//or SEE_MASK_NOCLOSEPROCESS
;
Info.lpVerb := '';
Info.lpFile := PChar(AExeFilename);
Info.lpParameters := PChar(AParams);
Info.lpDirectory := PChar(ExtractFilePath(AExeFilename));
Info.nShow := SW_SHOWNORMAL;
if not ShellExecuteEx(@Info) then …Run Code Online (Sandbox Code Playgroud) 我有DataSource1 (TDataSource),并且有一些DB-Aware控件链接到它(通过SomeDBControl.DataSource=DataSource1)
如何在代码中找出(枚举)哪些控件链接到给定的TDataSource?
我想写一个TCheckBox和TRadioButton后代有3个相同的方法.
TMyCheckBox = class(TCheckBox)
procedure DoSomething1;
procedure DoSomething2;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
end;
TMyRadioButton = class(TRadioButton)
procedure DoSomething1;
procedure DoSomething2;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
end;
// the following procedures are common for both classes, so in fact
// TMyCheckBox.DoSomething1 do the same as TMyRadioButton.DoSomething1
procedure DoSomething1;
begin
// here is the same code for TMyCheckBox as well as for TMyRadioButton
// but I don't want to write the same code many times …Run Code Online (Sandbox Code Playgroud) 我正在使用VT.Background在VT中显示带有几列的背景图像.
但我无法找到一种方法为细胞使用不同的颜色,因为它们隐藏了背景图像.
我曾尝试使用,OnBeforeItemErase但如果我使用EraseAction := eaColor单元格上的背景位图区域也正在绘制,如果我使用eaDefault的颜色没有被应用.
知道如何做到这一点?
如何使用我自己的自定义按钮(图像)来替换VST中的默认[-]/ [+]按钮?
我想用箭头代替(
,
),还支持RTL bidi模式(
,
).
编辑:我知道bsTriangle样式(ButtonStyle).它不尊重RTL.我想使用自己的自定义图像.
我正在寻找可TFlowPanel与D5一起使用的(或类似的)实现.
基本上我需要在(使用垂直滚动条)TFlowPanel内部工作TScrollBox,因此控件将根据宽度进行换行TScrollBox.
图像基本上显示了我需要的东西:

调整大小后,控件会自动重新定位:

使用垂直滚动条:

我正在使用此代码来静音/取消静音系统主音量:
const
APPCOMMAND_VOLUME_MUTE = $80000;
WM_APPCOMMAND = $319;
procedure TForm1.Button1Click(Sender: TObject);
begin
// toggle mute/unmute
SendMessageW(Handle, WM_APPCOMMAND, Handle, APPCOMMAND_VOLUME_MUTE);
end;
Run Code Online (Sandbox Code Playgroud)
(从/sf/answers/10788991/获取代码)
它在XP上工作正常(还没有在Win7上测试它).
我需要一种方法来检查(获取)当前的"静音"状态?它是否静音.
有任何想法吗?
更新:对于XP,我最终使用了这里的代码:如何在Windows XP中获取主卷?(感谢@Sertac Akyuz)
我不得不改变一行:
mxlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
Run Code Online (Sandbox Code Playgroud)
至:
mxlc.dwControlType := MIXERCONTROL_CONTROLTYPE_MUTE;
Run Code Online (Sandbox Code Playgroud)
返回值为0(不是静音)或1(静音).
继续我之前关于使用VCL接口的调查.
我想有一个代码示例来演示两者在哪里以及如何协同工作.或者两者的经典利益/用法是什么:
ISomething = interface
['{EFE0308B-A85D-4DF3-889C-40FBC8FE84D0}']
...
end;
TSomeThing = class(TSomeVCLObject, ISomething)
...
end;
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建带有扁平边框的TScrollBox而不是丑陋的“ Ctl3D”。
这是我尝试过的,但是边框不可见:
type
TScrollBox = class(Forms.TScrollBox)
private
procedure WMNCPaint(var Message: TWMNCPaint); message WM_NCPAINT;
protected
public
constructor Create(AOwner: TComponent); override;
end;
...
constructor TScrollBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
BorderStyle := bsNone;
BorderWidth := 1; // This will handle the client area
end;
procedure TScrollBox.WMNCPaint(var Message: TWMNCPaint);
var
DC: HDC;
R: TRect;
FrameBrush: HBRUSH;
begin
inherited;
DC := GetWindowDC(Handle);
GetWindowRect(Handle, R);
// InflateRect(R, -1, -1);
FrameBrush := CreateSolidBrush(ColorToRGB(clRed)); // clRed is here for testing
FrameRect(DC, R, FrameBrush);
DeleteObject(FrameBrush);
ReleaseDC(Handle, DC);
end; …Run Code Online (Sandbox Code Playgroud)