Hi guys,

I have a dialog, it is compiled into the app as a resource, and i have no problem loading it and killing it (i use CreateDialogParam to load it in when the 'F2' key has been pressed).

However, i have 3 edit boxes on that dialog. Once the dialog is showing, i would like to set the background of the edit boxes to a custom color, and put a single letter in each one. How should i go about this? Can i set the backcolor of a edit box, or should i use a richedit? Also, the SendDlgItemMessage call in my dlgWndProc causes an unhandled exception, is this because the edit box (resource id #1001) hasn't been created yet?

If you can answer this, pseudo code is fine. Below is what code i have so far:

In my WndProc, the handler for the 'F2' key:
--------------------------------------------------------
.ELSEIF uMsg == WM_KEYUP
.IF wParam == VK_F2
invoke CreateDialogParam, hInstance, 101, masterHwnd, ADDR dlgWndProc, 0
.IF !eax
invoke GetLastError
.ELSE
invoke ShowWindow, m_hWnd, SW_SHOW
.ENDIF
.ENDIF

and here is the code from my dlgWndProc:
------------------------------------------------
dlgWndProc proc m_hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

.IF uMsg == WM_INITDIALOG
invoke SendDlgItemMessage, m_hWnd, 1001, WM_SETTEXT, FALSE, addr g_sLETTER_A
ret

.ELSEIF uMsg == WM_COMMAND
mov ebx, wParam
.IF bx == IDCANCEL
invoke DestroyWindow, m_hWnd
ret
.ENDIF
.ENDIF

mov eax, FALSE
ret
dlgWndProc endp
Posted on 2001-10-10 07:09:11 by sluggy
Hi sluggy

Using ebx in a dlgproc without preserving it causes the crash.
Also you should return TRUE on all msg you handle in your proc.

Else your code should work.

KetilO
Posted on 2001-10-10 07:18:13 by KetilO
the text set during create is ok, fix the things told by KetilO,
to set the backcolor, you must respond in the dialog to the
WM_CTLCOLOREDIT and set the color to the given hdc.
Posted on 2001-10-10 08:07:15 by beaster
Excellent, thanks guys.
Posted on 2001-10-10 18:49:32 by sluggy