Having struggled to achieve my first simple (well it is in VB6) objective, I thought it might be of interest and help to other newbies like me.
Objective - To produce a window that -
1. Has a fixed size (Height & Width)
2. Is centered on the screen
3. Includes a custom icon
4. Omits the MINIMIZE & MAXIMIZE buttons
5. Is not resizable
Process
1. Run Prostart.exe (Located in \MASM32)
2. Use the following settings -
Use Toolbar - Unchecked
Use Statusbar - Unchecked
Project File Name - Prg01
Window Title - Prg01
Manual Size - Checked
Width - 300
Height - 250
Use Fixed Border - Unchecked
Code Options - ALL Unchecked
3 Set the path for the output using "Set Target Dir"
4 Select the "Create Project" button & then select "Yes" on the "Build" dialog
5 NOTE - If MASM32 is not in the root directory you will get the following error.
This assumes that you have already entered the revised paths in prostart.ini
Prg01.inc(15) : Fatal error A1000: cannot open file : \masm32\macros\macros.asm
This can be corrected by changing the path on line 15 of Prg01.inc
and rerunning "makeit.bat"
6. At this point we have code that satisfies the first two objectives.
7. To achieve the third objective a custom 16x16 .ico file was produced using IcoFX.exe.
(This is available as freeware from "http://icofx.ro/"
8. To Install the new Icon.
Copy new Icon file (ADir_Icon.ico) to Prg01 Directory
Change "rsrc.rc" resource definition file from -
500 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "Prg01.ico"
to -
500 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "ADir_Icon.ico"
Run Makeit.bat to recompile program
Execute Prg01.exe {new Icon now present in Caption Bar}
9. To remove the Minimize & Maximize Buttons from the Form we need to change the sub-class
A review of the "CreateWindowEx" API call shows that the buttons are controlled by dwstyle.
The existing program uses the constant WS_OVERLAPPEDWINDOW 0x00CF0000
This value is the equivalent of the following.
= WS_CAPTION 0x00C00000
+ WS_SYSMENU 0x00080000
+ WS_SIZEBOX 0x00040000
+ WS_MINIMIZEBOX 0x00020000
+ WS_MAXIMIZEBOX 0x00010000
The revised value required to remove MINIMIZEBOX & MAXIMIZEBOX is 0x00CC0000
10 This is implemented as follows
Add an item to the .data section in Prg01.inc
PrgWinSty dd 0
Add the following code in the start section after the global variables and immediately before "Call Main"
push eax
mov eax, 0CC0000h
mov PrgWinSty, eax
pop eax
Change the following code in "Main proc"
invoke CreateWindowEx,WS_EX_LEFT,
ADDR szClassName,
ADDR szDisplayName,
WS_OVERLAPPEDWINDOW,
Wtx,Wty,Wwd,Wht,
NULL,NULL,
hInstance,NULL
To
invoke CreateWindowEx,WS_EX_LEFT,
ADDR szClassName,
ADDR szDisplayName,
PrgWinSty,
Wtx,Wty,Wwd,Wht,
NULL,NULL,
hInstance,NULL
Run "makeit.bat" to recompile and run Prg01.exe to see the revised form.
(Objective 3 & 4 have now been achieved)
11 The final step of preventing resizing is now easy, all that is required is to change the
PrgWinSty value to 0C80000h and recompile.
All the original objectives have now been achieved, and it demonstrates how changing the constant values included in dwstyle will affect the form attributes created by "CreateWindowEx"
You will also be able to experiment with other form elements by changing the selected options in prostart.exe
Cheers
Tarka