Hello folks,
What is wrong with this code? I guess something's going wrong while processing the %WM_CTLCOLORSTATIC message.
This is what happens: when clicking the OK-button, the new text is mixed up with the original line (etc.).
Instead of an hollow brush, I've tried to use a solid brush, but then the label's background is black. And yes,
I know how to give the brush a different color, but which one? %LTGRAY is not the default dialog background on all
platforms (for instance: on NT4 it appears to be lighter). And finally: GetBkColor hLbl returns white; why not the
proper gray variant?
------------------
mailto:[email protected][email protected]</A>
www.basicguru.com/zijlema/
What is wrong with this code? I guess something's going wrong while processing the %WM_CTLCOLORSTATIC message.
This is what happens: when clicking the OK-button, the new text is mixed up with the original line (etc.).
Instead of an hollow brush, I've tried to use a solid brush, but then the label's background is black. And yes,
I know how to give the brush a different color, but which one? %LTGRAY is not the default dialog background on all
platforms (for instance: on NT4 it appears to be lighter). And finally: GetBkColor hLbl returns white; why not the
proper gray variant?
Code:
#COMPILE EXE #INCLUDE "WIN32API.INC" CALLBACK FUNCTION DlgCallBck() STATIC hLbl AS LONG LOCAL hFnt AS LONG, lf AS LOGFONT, hBrsh AS LONG, lb AS LOGBRUSH SELECT CASE CBMSG CASE %WM_INITDIALOG CONTROL HANDLE CBHNDL, 101 TO hLbl CONTROL SEND CBHNDL, 101, %WM_GETFONT, 0, 0 TO hFnt GetObject hFnt, SIZEOF(lf), BYVAL VARPTR(lf) lf.lfWeight = %FW_BOLD hFnt = CreateFontIndirect(lf) CONTROL SEND CBHNDL, 101, %WM_SETFONT, hFnt, 1 CONTROL SEND CBHNDL, %IDOK, %BM_SETSTYLE, %BS_DEFPUSHBUTTON, %TRUE CONTROL SET FOCUS CBHNDL, %IDOK FUNCTION = 1 CASE %WM_CTLCOLORSTATIC SetBkMode CBWPARAM, %TRANSPARENT SELECT CASE CBLPARAM CASE hLbl SetTextColor CBWPARAM, %RED ' ALTERNATIVE WAY: ' lb.lbStyle = %BS_SOLID ' lb.lbColor = %LTGRAY ' this does not work for NT4 ' hBrsh = CreateBrushIndirect(lb) ' END ALTERNATIVE WAY hBrsh = GetStockObject(%NULL_BRUSH) FUNCTION = hBrsh END SELECT CASE %WM_COMMAND IF CBCTL = %IDOK THEN CONTROL GET TEXT CBHNDL, 101 TO content$ IF INSTR(content$, "initial") THEN CONTROL SET TEXT CBHNDL, 101, "Modified" ELSE CONTROL SET TEXT CBHNDL, 101, "This is the initial line" END IF END IF CASE %WM_DESTROY DeleteObject hFnt DeleteObject hBrsh END SELECT END FUNCTION FUNCTION PBMain() AS LONG LOCAL hDlg AS LONG DIALOG NEW 0, " Test label colors", , , 200, 100, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg CONTROL ADD LABEL, hDlg, 101, " This is the initial line", 10, 10, 180, 10 CONTROL ADD BUTTON, hDlg, %IDOK, "OK", 140, 76, 50, 14 DIALOG SHOW MODAL hDlg CALL DlgCallBck END FUNCTION
mailto:[email protected][email protected]</A>
www.basicguru.com/zijlema/
Comment