WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Using Standard Windows bitmaps in dialogs


If you only need the standard windows icons you can use them without bitmaps with some tricks:
;Windows icons
;Guido 02/03

;----------------------------------------------------------------------------;
;DrawIcon : Draws a standard windows icon.                                   ;
;----------------------------------------------------------------------------;
;hdlg     : dialog handle                                                    ;
;x , y    : position in pixels of the icon inside the dialog                 ;
;icontype : One of the following values:                                     ;
;            IDI_APPLICATION = 32512                                         ;
;            IDI_HAND        = 32513                                         ;
;            IDI_QUESTION    = 32514                                         ;
;            IDI_EXCLAMATION = 32515                                         ;
;            IDI_ASTERISK    = 32516                                         ;
;            IDI_WINLOGO     = 32517                                         ;
;Returns  : handle of the static control used for the icon.                  ;
;----------------------------------------------------------------------------;
#definefunction DrawIcon(hdlg,x,y,icontype)
user32=strcat(dirwindows(1),"user32.dll")

WS_CHILD=1073741824
WS_VISIBLE=268435456
SS_ICON=3
STM_SETICON=368

;get icon handle
hicon=dllcall(user32,long:"LoadIconA",lpnull,long:icontype)

;static control
hstatic=dllcall(user32,long:"CreateWindowExA",long:0,lpstr:"Static",lpstr:"",long:WS_CHILD|WS_VISIBLE|SS_ICON,long:x,long:y,long:0,long:0,long:hdlg,long:0,long:dllhinst(""),long:0)

;set icon
dllcall(user32,long:"SendMessageA",long:hstatic,long:STM_SETICON,long:hicon,long:0)
return hstatic
#endfunction


;------------------------------------------------------
;TEST
;------------------------------------------------------
#Definefunction dialogproc(hdlg,msg,id,p4,p5)
Switch msg
  Case 0 ;Init
    DialogProcOptions(hdlg,2,1) ;Push buttons

    ;icon types
    IDI_APPLICATION = 32512
    IDI_HAND        = 32513
    IDI_QUESTION    = 32514
    IDI_EXCLAMATION = 32515
    IDI_ASTERISK    = 32516
    IDI_WINLOGO     = 32517

    ;put some icons
    DrawIcon(hdlg,0,0,IDI_HAND)
    DrawIcon(hdlg,50,0,IDI_QUESTION)
    DrawIcon(hdlg,100,0,IDI_EXCLAMATION)
    DrawIcon(hdlg,150,0,IDI_ASTERISK)
    
    Break                 

  Case 2 ;Button pushed
    Switch id
      Case 1 ;OK 
        Return -1
        Break
      Case 2 ;cancel
        Return -1
        Break
  EndSwitch
EndSwitch
Return -1
#Endfunction


MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`Windows Icons`
MyDialogX=-1
MyDialogY=-1
MyDialogWidth=318
MyDialogHeight=174
MyDialogNumControls=002
MyDialogProcedure=`dialogproc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=4513660

MyDialog001=`081,153,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`201,153,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog",1)

Article ID:   W15925
File Created: 2004:03:30:15:41:42
Last Updated: 2004:03:30:15:41:42