I have read the tutorial included in masm32 package in /example8/mob/CWS/ and also several others on how to make irregular windows or custom shaped windows and all show you how to do it using
invoke getmodulehandle...
mov hInstance, eax
invoke WinMain
invoke Exitprocess...
WinMain PROC....
.....
Invoke CreateWindowEx,....
Now the problem with it is that you'll have to create the buttons and registering them which is too annoying instead of using a .rc and .res file so i tried to make it using DialogBoxParam and using .rc file but it never worked after many frustrating tries :'(, Is it possible to make it using DialogBoxParam ?
Seems like following are the important parts that have to be entered before creating the window
Set the bitmap loaded as background
; --> LOAD BITMAP FROM EXECUTABLE (RESOURCE)
invoke LoadBitmap,hInst,1000
; --> USE THAT BITMAP AS WINDOW BACKGROUND
invoke CreatePatternBrush,eax
mov wc.hbrBackground,eax
Calculates the Correct image height and width and then it passes them into CreateWindowEx
; --> CALCULATE THE MIDDLE OF THE SCREEN FOR OUR WINDOW
; 1. get width of the screen
; 2. divide it
; 3. get the width of our BG-Picture
; 4. divide it
; 5. horizontal middle = value of step 2 - value of step 4
; 6. ... do the same with screen/picture height ...
invoke GetSystemMetrics,SM_CXSCREEN
shr eax,1
sub eax,PictureW/2
push eax
invoke GetSystemMetrics,SM_CYSCREEN
shr eax,1
sub eax,PictureH/2
pop ebx
Here the correct height,width of the image are passed plus it is made POP-UP without any caption etc..
; --> CREATE OUR WINDOW (WITH POPUP STYLE!)
invoke CreateWindowEx,WS_EX_LEFT,ADDR ClassName,ADDR DisplayName,
WS_POPUP,ebx,eax,PictureW,PictureH,NULL,NULL,hInst,NULL
mov hWnd,eax
It is all done before the window is created,all set and done and after it
.IF uMsg == WM_CREATE
; --> LOAD REGION_DATA (SEE API REF FOR QUESTIONS)
invoke FindResource,hInstance,addr RsrcName,addr RsrcType
mov RsrcHand, eax
invoke LoadResource,hInstance,eax
mov RsrcPoint, eax
invoke SizeofResource,hInstance,RsrcHand
mov RsrcSize, eax
invoke LockResource,RsrcPoint
mov RsrcPoint, eax
; --> CREATE REGION AND PASS IT TO OUR WINDOW
invoke ExtCreateRegion,NULL,RsrcSize,eax
invoke SetWindowRgn,hWin,eax,TRUE
It Loads the RGN data and set the RGN. Before it everything is done i.e correct window position, size etc..
I don't know how i'll do the above part (calculating position,size)...trying to do something like this simply causes errors or results in the window not being shown correctly
invoke GetSystemMetrics,SM_CXSCREEN
shr eax,1
sub eax,PictureW/2
push eax
invoke GetSystemMetrics,SM_CYSCREEN
shr eax,1
sub eax,PictureH/2
pop ebx
; --> CREATE OUR WINDOW (WITH POPUP STYLE!) [b]Instead of
CreateWindowEx i used DialogBoxParam here[/b]
Invoke DialogBoxParam...........
Any help ? I started feeling like it's not possible using DialogBoxParam :( ?
There is no such word impossible in asm... I've made a dialog version of that example (see attachment)
The only difference is that dialog has no background brush assoc. so you must return the brush during WM_CTLCOLORDLG message...
I hope you know what is a region generator (I've extracted that resource as *.bin) and the fact that it's used to compose a complex shape from pictures etc...
[attachment deleted by admin]
Here's an idea: create a transparent window with no border, standard buttons, etc., and then use the WM_PAINT message to stick on the client area whatever stuff you want on your window. For buttons, you can also make buttons with custom bitmaps. Look up CreateWindowEx documentation on MSDN - found in Microsoft's website if you don't have a copy of MSDN - and follow the trail there on the subject of making button windows. You can use device context drawing functions to draw whatever the heck you want on your buttons! (Personally, I'd get creative and make a discontiguous polymorphic window with organic-looking polymorphic controls that move around and form out of the window or melt into it. It'd be like some crazy freak liquid monster of a window!! That'd be freakin' cool!!! :toothy)
can't believe how easy it was :lol :toothy thanks ramguru & JFG :U
OK, now I have a question. Has anybody ever made a custom window shape on a child window? Can it be done? Ratch
QuoteOK, now I have a question. Has anybody ever made a custom window shape on a child window? Can it be done? Ratch
just like ramguru said there is no word impossible in asm :). I've edited the example made by ramguru a bit to show you how to make custom window shapes on child windows :8). I've used .rgn file because i felt comfortable with it instead of to extract resources from it and saving as *.bin so you'll need RGN Generator (i found this site while searching for RGN Generator...contains the app plus the source code of it too, cool eh ? :wink http://www.codeproject.com/gdi/rgncreator.asp).
PS: I think this example should be included in masm32's next version because maybe somebody else needs to use this method so he can take a look at it directly from masm32 examples :wink
Regards
[attachment deleted by admin]
hi falcon,
Very nice example! I like ramguru's, also.
Paul
Quote from: PBrennick
hi falcon,
Very nice example! I like ramguru's, also.
Paul
thanks :)
btw i forgot to mention, i converted it from RadAsm project to just simple masm32 so you will have to use QEditor to compile it :wink or maybe convert it back to RadAsm :P.
Hi to all,
It's quite interesting to see others imagination at work. :U I hope you guys don't mind that I learn from your examples. For me, I simply like to learn different stuff.
Thank you all,
LL
You can do this in c++ as well, not just asm, its really all just win32 in the end.
Hi again,
I wanted to change the font size to: "FONT 6,"MS Serif"" instead of "FONT, 8,"MS Sans Serif". When I did, the bottom of the picture was being cut off. Why was this happening ? I've played with the values for the size of the dialogbox to see if I could correct this and I came up with the value of: "IDD_DIALOG1 DIALOGEX 6,6,200,210" instead of "IDD_DIALOG1 DIALOGEX 6,6,200,184". Can anyone shed some information on why this correction was needed to show all of the picture ?
Thank you,
LL
Not having used dialogs a lot (at all) I can only suggest that perhaps the 'height' of the dialog is based on the font size, so that if a user has a larger font set the dialog will still enclose it.
Hi Zooba,
Thank you for your reply. I would agree, however I was trying a smaller font size.The other guys were using: "FONT, 8, MS Sans Serif" and I was trying a smaller font: "FONT 6,"MS Serif". If it would of been the reverse, I would of said that the font size was trying to adjust accordingly (Bigger font takes more room to display, therefore cut off the bottom of the picture). Ah well ! Learning and adjusting ones programs to make it work. Again, thank you !
LL
Bitmaps and regions don't mix well with dialog boxes. In general it's a bad idea to use dialogs with custom shapes, unless you somehow compensate for not knowing the exact size in pixels of the dialog in the user's display.
For example, the region can be calculated on runtime and the bitmap stretched. Another option is to use a vector graphic instead of a bitmap, and a polygon region instead of one made of rectangles.
But the best I think is not to use dialog boxes at all (for this)... :toothy
Hi QvasiModo,
I did learn how to do a "skined window" following Hiroshimator example. However, it seems to open a little slower than using a dialogbox. Like many, I was curious to see how things in assembly are done. I do things and then JMP to something else. Thank you for your reply ! :toothy
LL