API - Create window help

Archives Forums/Win32 Discussion/API - Create window help

EOF(Posted 2006) [#1]
I'm playing around with WinAPI but getting bogged down with the ins and outs of windows controls.

I have a bit of code which displays a window and reports all WM messages to the WINPROCHANDLER() function.

Example Code - API Window (BlitzMax)

The main problems I have is,

1) How should I fill in the client area of the window?
This area is initially WHITE and shows the window title in the upper/left part:



However, moving the window around or moving other windows in front shows the inner area is not being drawn.
This image shows the area I wish to be permanently solid.
(The BLUE is the desktop background):



I'm not sure what to do here. So ...

1) Should I fill in the client area with a DC of the same size?
2) Is there a flag which does this for me?
3) How do I accurately get the correct client area/coordinates. Afterall, there are all sorts of parameters which affect the windows inner area (titlebar/statusbar, borders, etc..)
4) What if the user resizes/moves the window?
Again, how should I update the inner area?


Pineapple(Posted 2006) [#2]
Not sure if this is much use:-



Basically, you call a WinAPI (GDI) function called UpdateWindow(hWnd), this sends a WM_PAINT event to your call back function, then you can draw your updated window again!

Dabz


EOF(Posted 2006) [#3]
Thanks Dabz but no luck yet. I get bewildered at the number of commands available for drawing windows, buttons and the likes.

I read up on InvalidateRect which seems like the right command to use but still no joy.

Maybe I am supposed to fill in the area with a STATIC borderless window(??) .. don't know really.


Kev(Posted 2006) [#4]
Jim, under normal usage you would call DefWindowProc() but hooking into blitzmax needs a little more work.

see this post here from a couple of months ago. where full hooking of blitzmax takes place.

http://www.blitzbasic.com/Community/posts.php?topic=50237

this should be of some help

kev


skidracer(Posted 2006) [#5]
Check the hbrBackground member of your window class.


EOF(Posted 2006) [#6]
Ok folks. Thanks so far.

I think I've got the structure of MSG wrong though.
During the running of the program I get:

bad refs:obj=$e107a0 refs=$0

Here is how I have defined the structure using this C++ sample ..
typedef struct tagPOINT { // pt  
    LONG x; 
    LONG y; 
} POINT; 

typedef struct tagMSG {     // msg  
    HWND   hwnd;	 
    UINT   message; 
    WPARAM wParam; 
    LPARAM lParam; 
    DWORD  time; 
    POINT  pt; 
} MSG; 


Blitzmax
Type POINTAPI
	Field x%,y%
End Type

Type MESSAGE
    Field hWnd%
    Field Message%
    Field wParam:Byte Ptr
    Field lParam:Byte Ptr
    Field Time%
    Field pt:POINTAPI=New POINTAPI
End Type 

The problem seems to arise after GetMessage()
I've got a feeling its something to do with

Field pt:POINTAPI=New POINTAPI

Maybe that should be a byte ptr?

Latest version -> API Window (BlitzMax)