|
-
Aug 13th, 2002, 10:08 AM
#1
Thread Starter
Addicted Member
-
Aug 13th, 2002, 11:15 AM
#2
Frenzied Member
Here is how you could change the backcolor of a dialog:
PHP Code:
HBRUSH g_hbrBackground = CreateSolidBrush(RGB(0,255,0));
case WM_CTLCOLORDLG:
return (LON)g_hbrBackGround;
case WM_CTLCOLORSTATIC:
{
HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(255,255,255));
SetBkMode(hdcStatic,TRANSPARENT);
return (LONG)g_hbrBackground;
}
break;
-
Aug 13th, 2002, 11:59 AM
#3
Thread Starter
Addicted Member
Where do I insert this code in Dialog based window?
Does it have to be in window message hanling function?
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)?
-
Aug 13th, 2002, 12:06 PM
#4
Frenzied Member
Yes.
Here is an example:
PHP Code:
#include <windows.h>
#include "resource.h"
HBRUSH g_hbrBackground = NULL;
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
g_hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(NULL,
MAKEINTRESOURCE(IDI_APPLICATION)));
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(NULL,
MAKEINTRESOURCE(IDI_APPLICATION)));
break;
case WM_CLOSE:
EndDialog(hwnd, 0);
break;
case WM_CTLCOLORDLG:
return (LONG)g_hbrBackground;
case WM_CTLCOLORSTATIC:
{
HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(255, 255, 255));
SetBkMode(hdcStatic, TRANSPARENT);
return (LONG)g_hbrBackground;
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
EndDialog(hwnd, 0);
break;
}
break;
case WM_DESTROY:
DeleteObject(g_hbrBackground);
break;
default:
return FALSE;
}
return TRUE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|