hello geeks out there,

I have few problems in my way of making a registry tweaker.

1.)I am unable to colour button of dialog boxes.I have used the message wm_ctlcolorbtn but no use.I have searched the board but couldn't find a satisfactory answer.

2.)Whenever I try to add some controls to my dialog box (i am using winasm) like animation control,progress bar,calendar my application don't work.I mean with certain controls the application refuses to launch

3.)I have created a about dialog box as you can see below and i want to display the message in it.Now both TextOut and DrawText are not working in it.Then I tried to put the text in the caption of a static control but now i am unable to adjust it font.How could i do that?

.386
.model flat,stdcall
option casemap:none
DlgProcMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
DlgProcAbout PROTO :DWORD,:DWORD,:DWORD,:DWORD

include /masm32/include/windows.inc
include /masm32/include/kernel32.inc
include /masm32/include/user32.inc
include /masm32/include/gdi32.inc
includelib /masm32/lib/user32.lib
includelib /masm32/lib/kernel32.lib
includelib /masm32/lib/gdi32.lib


RGB macro red,green,blue
        xor eax,eax
        mov ah,blue
        shl eax,8
        mov ah,green
        mov al,red
endm

.DATA
mystr db "Mohit Garg Presents OPTIMA",0
DlgNameMain db "IDD_DLG1010",0
DlgNameAbout db "IDD_DLG1024",0
IDB_MAIN equ 10025
IDC_BUTTON1017 equ 1017
IDC_BUTTON1018 equ 1018
IDC_BUTTON1025 equ 1025
FontName db "script",0
.DATA?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hbitmap dd ?
.CODE
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,1010,NULL,addr DlgProcMain,NULL
invoke ExitProcess,eax

DlgProcMain proc hwnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
        LOCAL ps:PAINTSTRUCT
        LOCAL rc:RECT
        LOCAL hdc:HDC
        LOCAL hmem:HDC
      .IF uMsg==WM_PAINT
              invoke LoadBitmap,hInstance,10025
              mov hbitmap,eax
              invoke BeginPaint,hwnd,ADDR ps
              mov hdc,eax
              invoke CreateCompatibleDC,hdc
              mov hmem,eax
              invoke SelectObject,hmem,hbitmap
              invoke GetClientRect,hwnd,ADDR rc
              invoke BitBlt,hdc,0,0,rc.right,rc.bottom,hmem,0,0,SRCCOPY
              invoke DeleteDC,hmem
              invoke EndPaint,hwnd,addr ps
              mov eax,TRUE     
              ret       
        .ELSEIF uMsg==WM_COMMAND
        mov eax,wParam
        and eax,0ffffh
        .IF  eax==1017
          invoke PostQuitMessage,NULL
        .ELSEIF eax==1018
        invoke DialogBoxParam,hInstance,1024,hwnd,addr DlgProcAbout,NULL       
        .ENDIF
        mov eax,TRUE
        ret
        .ELSEIF uMsg==WM_CTLCOLORBTN
        invoke SetBkMode,wParam,TRANSPARENT
        invoke SetBkColor,wParam,Black
        invoke GetStockObject,BLACK_BRUSH
        ret
        .ELSEIF
                    mov eax,FALSE
          Ret
          .ENDIF
DlgProcMain EndP
DlgProcAbout proc  hwnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL ps:PAINTSTRUCT
LOCAL hdc:HDC
LOCAL hbr:HBRUSH
LOCAL rc:RECT
LOCAL hfont:HFONT
RGB 255,115,60
invoke CreateSolidBrush,eax
mov hbr,eax
.IF uMsg==WM_CTLCOLORDLG
mov eax,hbr
ret
RGB 255,115,60
invoke CreateSolidBrush,eax
mov hbr,eax
.ELSEIF uMsg==WM_CTLCOLORSTATIC
invoke SetTextColor, wParam, hbr
invoke SetBkMode, wParam, TRANSPARENT
invoke GetStockObject,NULL_BRUSH
ret
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
and eax,0ffffh
.IF eax==1025
invoke EndDialog,hwnd,NULL
.ENDIF
mov eax,TRUE
ret
.ELSEIF
mov eax,FALSE
ret
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hwnd,ADDR ps
mov hdc,eax
invoke GetClientRect,hwnd,addr ps
invoke TextOut,hdc,0,0,ADDR mystr,SIZEOF mystr
invoke EndPaint,hwnd, ADDR ps
mov eax,TRUE
ret
.ENDIF
DlgProcAbout EndP
end start




;This Resource Script was generated by WinAsm Studio.

#define IDD_DLG1010 1010
#define IDC_COMBOBOX1012 1012
#define IDC_BUTTON1016 1016
#define IDC_BUTTON1017 1017
#define IDC_BUTTON1018 1018
#define IDB_MAIN 10025
#define IDD_DLG1024 1024
#define IDC_BUTTON1025 1025
#define IDC_STATIC1027 1027

IDB_MAIN BITMAP DISCARDABLE "c:\img.bmp"

IDD_DLG1010 DIALOGEX 0,0,410,223
FONT 8,"MS Sans Serif"
STYLE 0x90000800
EXSTYLE 0x00040309
BEGIN
CONTROL "IDC_COMBOBOX1012",IDC_COMBOBOX1012,"ComboBox",0x50010003,10,18,394,68,0x00000000
CONTROL "Apply",IDC_BUTTON1016,"Button",0x50010000,23,58,81,16,0x00000000
CONTROL "Exit",IDC_BUTTON1017,"Button",0x50010000,143,58,81,16,0x00000000
CONTROL "About Me",IDC_BUTTON1018,"Button",0x50010000,270,58,81,16,0x00000000
END

IDD_DLG1024 DIALOGEX 0,0,269,146
FONT 8,"MS Sans Serif"
STYLE 0x90000800
EXSTYLE 0x00040309
BEGIN
CONTROL "Thanks",IDC_BUTTON1025,"Button",0x50010000,160,123,60,19,0x00000000
CONTROL "Mohit Garg Presents                                                            OPTIMA                                                                                (The ultimate registry Tweaker)",IDC_STATIC1027,"Static",0x50000000,8,5,188,87,0x00000000
END


Posted on 2006-04-22 16:05:25 by lonelyboy
1. wm_ctlcolorbtn does not actually work for push buttons , it is meant for static buttons like group boxes etc...

2. For these classes you must call InitCommonControls before you call DialogBoxParam

3. Too much code to read so I'll leave that to someone else ;)

Posted on 2006-04-22 16:47:44 by donkey

2. For these classes you must call InitCommonControls before you call DialogBoxParam


Many MAny thanks for this
8)

wm_ctlcolorbtn does not actually work for push buttons , it is meant for static buttons like group boxes etc...


Really ?

Too much code to read so I'll leave that to someone else


You have already done much my friend on your behalf.Thanks for let me steal your some precious moments

Posted on 2006-04-22 17:02:12 by lonelyboy
You'll need to look up "owner drawn buttons" - it's not as bad as it might sound initially :)
Posted on 2006-04-22 17:38:33 by f0dder
3.)I have created a about dialog box as you can see below and i want to display the message in it.Now both TextOut and DrawText are not working in it.Then I tried to put the text in the caption of a static control but now i am unable to adjust it font.How could i do that?


If you are using RadASM you can use my font builder addin (on the Project menu) or fill in the following...

Arial_10 LOGFONT <-13,0,0,0,400,0,0,0,0,3,2,1,34,"Arial">

The font size (10pt = -13) is calculated as follows

invoke GetDC,hwnd
mov hDC,eax
invoke GetDeviceCaps,hDC,LOGPIXELSY
mul PtSize
mov ecx,72
div ecx
neg eax
mov LogSize, eax
invoke ReleaseDC, hwnd, hDC


To create the font using the structure above...
invoke CreateFontIndirect,offset Arial_10
mov ,eax


To apply the font to the static control, given that the ID of the static is in IDSTATIC

invoke SendDlgItemMessage, hDlg, IDSTATIC, WM_SETFONT, hFont, TRUE
Posted on 2006-04-22 19:44:39 by donkey