HellSpider Posted September 18, 2009 Posted September 18, 2009 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, 2001invoke SendMessage, edi, WM_SETICON,TRUE,eaxinvoke SetWindowText, edi, offset lpAppNameinvoke SetWindowPos,edi,HWND_TOPMOST,0,0,0,0,SWP_NOACTIVATE + SWP_NOMOVE + SWP_NOSIZEinvoke LoadBitmap, hInstance, 2003invoke CreatePatternBrush,eaxmov hBrush,eaxinvoke FindResource,hInstance,2000, RT_RCDATAmov hRegionInfo,eaxinvoke LoadResource,hInstance,eaxmov hRegionData,eaxinvoke SizeofResource,hInstance, hRegionInfomov sizeRsrc,eaxinvoke LockResource,hRegionDatamov pRsrc,eaxinvoke ExtCreateRegion,NULL,sizeRsrc,pRsrcinvoke SetWindowRgn,hDlg, eax, TRUEret... And: .ELSEIF uMsg == WM_CTLCOLORDLGmov eax, hBrushjmp @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 .
Loki Posted September 18, 2009 Posted September 18, 2009 Have you editted the bitmap after creating the region?What tool did you use to create it?
evlncrn8 Posted September 18, 2009 Posted September 18, 2009 looks like you haven't subtracted / taken into account the caption size, which would cause something like this
HellSpider Posted September 18, 2009 Author Posted September 18, 2009 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 .
evlncrn8 Posted September 18, 2009 Posted September 18, 2009 (edited) GetSystemMetrics(SM_CYCAPTION)would be what you'd need to call to get the height of the window caption (title)push SM_CYCAPTIONcall GetSystemMetricsor.. 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 locationyou 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 rightthen also try using no themes, see if it looks right too, just to ensureyou got the maths right for it on all systems, and not just your own Edited September 18, 2009 by evlncrn8
HellSpider Posted September 18, 2009 Author Posted September 18, 2009 (edited) 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 . Edited September 18, 2009 by HellSpider
HellSpider Posted September 19, 2009 Author Posted September 19, 2009 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 .
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now