Jump to content
Tuts 4 You

Irregular shaped applications


HellSpider

Recommended Posts

Hi.

I've started to learn coding with MASM and I'm coding a program with an irregular shape atm. The problem is that my region and the bitmap that should get placed on the region are not one the same place. The bitmap is like one centimeter below the region. So what I'm asking is for a solution to fix this.

Here is a picture of the mismatch of the region and the bitmap:

>http://img9.imageshack.us/img9/8807/regionbitmapmismatch.jpg

Now my code looks like this:

...
invoke LoadIcon, hInstance, 2001
invoke SendMessage, edi, WM_SETICON,TRUE,eax
invoke SetWindowText, edi, offset lpAppName
invoke SetWindowPos,edi,HWND_TOPMOST,0,0,0,0,SWP_NOACTIVATE + SWP_NOMOVE + SWP_NOSIZE
invoke LoadBitmap, hInstance, 2003
invoke CreatePatternBrush,eax
mov hBrush,eax
invoke FindResource,hInstance,2000, RT_RCDATA
mov hRegionInfo,eax
invoke LoadResource,hInstance,eax
mov hRegionData,eax
invoke SizeofResource,hInstance, hRegionInfo
mov sizeRsrc,eax
invoke LockResource,hRegionData
mov pRsrc,eax
invoke ExtCreateRegion,NULL,sizeRsrc,pRsrc
invoke SetWindowRgn,hDlg, eax, TRUE
ret
...

And:

.ELSEIF uMsg == WM_CTLCOLORDLG
mov eax, hBrush
jmp @ExitGuiDlg ; Jumps to a RETN (doesn't modify EAX in any way).

Post below if you need to see more code (although this is the only code related to the region) or anything else I could do, thanks :).

Link to comment

Have you editted the bitmap after creating the region?

What tool did you use to create it?

Nope, the bitmap hasn't been changed since I created the region data. I used RGN Generator 1.01.

looks like you haven't subtracted / taken into account the caption size, which would cause something like this :)

Any idea on how to do something like that? I'm still a beginner with MASM ;).

Link to comment

GetSystemMetrics(SM_CYCAPTION)

would be what you'd need to call to get the height of the window caption (title)

push SM_CYCAPTION

call GetSystemMetrics

or.. because you're using invoke (which i never liked.. but each to their own)..

invoke GetSystemMetrics, SM_CYCAPTION

; eax = height of caption, subtract this from your current location

you might also need to do SM_CYBORDER too, for the border height too...

experiment a little, that api should be all you need to get it looking right

then also try using no themes, see if it looks right too, just to ensure

you got the maths right for it on all systems, and not just your own

Edited by evlncrn8
Link to comment

GetSystemMetrics(SM_CYCAPTION)

would be what you'd need to call to get the height of the window caption (title)

push SM_CYCAPTION

call GetSystemMetrics

or.. because you're using invoke (which i never liked.. but each to their own)..

invoke GetSystemMetrics, SM_CYCAPTION

; eax = height of caption, subtract this from your current location

you might also need to do SM_CYBORDER too, for the border height too...

experiment a little, that api should be all you need to get it looking right

then also try using no themes, see if it looks right too, just to ensure

you got the maths right for it on all systems, and not just your own

Right. So I used the API to find out the values. Caption is 14px and the border is 1px. So I can assume that I got the picture 16px down (14px+1px+1px).

Is there any API to either modify the infos (wouldn't that be kinda global on the computer?) or some API to move the bitmap? Or am I completely lost (wouldn't be surprised). I searched a while at MSDN but didn't find anything useful :ermm:.

Edited by HellSpider
Link to comment

Ok. Got it working. The problem was that even if I did disable WS_CAPTION in the resources, WinAsm made a caption if there was something input in the caption text form (there is a default input). So now everything is working as it should. Thanks for all the help and suggestions :).

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...