digitalmars.D.learn - How change window Backgound Color when press a Button when using
- Marcone (59/59) Jan 29 2020 I created a GUI using "ResEdit Resource Editor" and embeded to
- bauss (4/7) Jan 29 2020 You need to handle WM_ERASEBKGND
- Marcone (2/11) Jan 29 2020 I am very noob. Can you send me the code?
- Mike Parker (19/20) Jan 29 2020 You've been asking a lot of questions about the Win32 API. This
I created a GUI using "ResEdit Resource Editor" and embeded to Dlang using this code above. Now I want to change the window Backgound Color when press a Button. How can I make it? import core.sys.windows.windows; import core.sys.windows.commctrl; import std.stdio; pragma(lib, "gdi32.lib"); pragma(lib, "comctl32.lib"); enum IDD_DIALOG1 = 100; enum BT_1 = 40000; HINSTANCE hInst; extern(Windows): BOOL DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) nothrow { switch(uMsg) { case WM_INITDIALOG: { } return TRUE; case WM_CLOSE: { EndDialog(hwndDlg, 0); } return TRUE; case WM_COMMAND: { switch(LOWORD(wParam)) { case BT_1: { try { // When press button the background need change to red for exemple. } catch(Exception) { } return true; } default: { break; } } } return TRUE; default:{ } } return FALSE; } int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { hInst=hInstance; InitCommonControls(); return DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, &DlgMain); }
Jan 29 2020
On Thursday, 30 January 2020 at 03:49:29 UTC, Marcone wrote:I created a GUI using "ResEdit Resource Editor" and embeded to Dlang using this code above. Now I want to change the window Backgound Color when press a Button. How can I make it?You need to handle WM_ERASEBKGND And then you can set it using CreateSolidBrush and SetClassLongPtr with GCLP_HBRBACKGROUND
Jan 29 2020
On Thursday, 30 January 2020 at 04:29:42 UTC, bauss wrote:On Thursday, 30 January 2020 at 03:49:29 UTC, Marcone wrote:I am very noob. Can you send me the code?I created a GUI using "ResEdit Resource Editor" and embeded to Dlang using this code above. Now I want to change the window Backgound Color when press a Button. How can I make it?You need to handle WM_ERASEBKGND And then you can set it using CreateSolidBrush and SetClassLongPtr with GCLP_HBRBACKGROUND
Jan 29 2020
On Thursday, 30 January 2020 at 04:31:46 UTC, Marcone wrote:I am very noob. Can you send me the code?You've been asking a lot of questions about the Win32 API. This is a D programming forum, not a Win32 API forum. I'm sure people are generally happy to help point you in the right direction, but you can't rely on anyone to send you code for it. Not many people are doing Win32 API programming in D (and I would guess a large percentage of the community here have never touched it). You really need to be following a Win32 API tutorial to learn this stuff. I don't personally know how good any online Win32 tutorials are, but I do know that the book "Programming Windows 5th Edition" is an excellent resource for learning Win32 programming: https://amzn.to/37C6htu It's available in both hardcover and Kindle editions. If you can afford to get it, I highly recommend you do. Several years ago, Andrej Mitrovic translated many of the examples from that book to D. Even if you don't buy the book, this will be a good resource to help you: https://github.com/AndrejMitrovic/DWinProgramming
Jan 29 2020