私は Win32 プログラムに取り組んでおり、コントロールを有効または無効にしたいと考えています。Windows XP のテーマとフォントを使用しています。STATIC コントロールを無効にすると、使用されているフォントが間違っているように見えます。
有効なコントロール:
無効なコントロール:
この画像では、私が何を意味するかは明らかです。
このコードはフォントを作成します(Googleを使用して見つけました):
HFONT CreateControlFont( void )
{
// Get the system message box font
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(ncm);
// If we're compiling with the Vista SDK or later, the NONCLIENTMETRICS struct
// will be the wrong size for previous versions, so we need to adjust it.
// In versions of Windows prior to Vista, the iPaddedBorderWidth member
// is not present, so we need to subtract its size from cbSize.
#if( WINVER < 0x0600 )
ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth);
#endif
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
return CreateFontIndirect(&(ncm.lfMessageFont));
}
を使用してコントロールに適用しますSendMessage(MY_WINDOW_HANDLE, WM_SETFONT, (WPARAM)MY_FONT, MAKELPARAM(FALSE, 0));
。
このコードを使用して XP スタイルを適用します (これもインターネットから):
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' \
version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' \
language='*'\"")
これは、STATIC コントロールを作成する方法です。
HWND CreateLabel( const TCHAR * text, int x, int y, int w, int h, HMENU id, HWND parent )
{
return CreateWindow(
"static", text, WS_CHILD | WS_VISIBLE, x, y, w, h, parent, id, hInstance, NULL);
}
私が使用するコントロールを無効にするにはEnableWindow(MY_WND_HANDLE, FALSE);
.
ご覧のとおり、コントロールがグレー表示されている場合を除いて、これは期待どおりに機能します。私は何を間違っていますか?