Two Windows API Questions

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Two Windows API Questions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:46 am

by Brendan Doolan >> Wed, 15 Dec 1999 3:35:22 GMT

Hi all,
I have a couple of questions I hope one of the Windows API wizards out there can help me with.

1. I want to create a form without a title bar and create my own (with rounded corners etc). What I want to be able to do is to allow the user to click and hold on the replacement title bar and allow the form to be dragged (but only when the replacement title bar is clicked). Can anyone tell me how to do this?

2. Does anyone know how to create a shadow effect for a form or a control? The important thing about the shadow effect is that it must be see through so that the form underneath will still show through the shadow. This is not the same as transparent where you don't see the transparent area at all.

Thanks for the help,
Brendan

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Two Windows API Questions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:46 am

by Eric Peachey >> Wed, 15 Dec 1999 21:00:31 GMT

Hello Brendan,
1. I want to create a form without a title bar and create my own (with rounded corners etc). What I want to be able to do is to allow the user to click and hold on the replacement title bar and allow the form to be dragged (but only when the replacement title bar is clicked). Can anyone tell me how to do this?

I think all you need to do is defined below. Somebody else gave me these so can't answer detailed questions.


Eric in Dunedin


This is the mouse down event for your picture control (your new gucci title bar thing say):

picGucciTitlebar_mouseDown(pict: Picture input; button: Integer; shift: Integer;
x: Real; y: Real) updating;

vars
begin

moveForm(self.hwnd);
end;




This is the moveForm method:


moveForm(hwnd:Integer);

constants
WM_SYSCOMMAND : Integer = #112;
WM_LBUTTONUP : Integer = #202;
MOUSE_MOVE : Integer = #f012;
SC_MOVE : Integer = #f010;
vars
begin

// This method allows for the movement of a form by directly accessing windows - the same as would happen
// if you clicked and dragged the standard windows blue tool bar at the top of each form. This method gives
// the ability to suppress the windows blue toolbar and use your own layout instead. If you turn off the
// pc's control panel setting to 'show windows while dragging', the movement will show a phantom rectangle
// being moved around the screen.

// To set up the external function do the following:
// 1) Go to External Function browser
// 2) Add library - user32
// 3) Add external function - name = sendMessage
// entry point = sendMessage
// library = user32
// 4) Define sendMessage signature as follows:
// sendMessage(hwnd:Integer;msg:Integer;lParam:Integer;wParam:Integer):Integer is SendMessageA in user32

call sendMessage(hwnd,WM_LBUTTONUP,0,0);
call sendMessage(hwnd,WM_SYSCOMMAND,MOUSE_MOVE,0);
end;




The sendMessage external function (may already be defined in RootSchema (was in Jade 4.2 anyway)


sendMessage(hwnd:Integer; msg:Integer; wparam:Integer; lparam:Integer):Integer is SendMessageA in user32;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Two Windows API Questions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:46 am

by Sean Clements >> Wed, 15 Dec 1999 21:00:40 GMT

Hi Brendan,
I can answer the first of your questions, and would be very interested to know how to do the second...

I use a user32 call of sendMessage to provide the functionality that you require. I place the following method against Window class :

moveForm(hwnd:Integer);

constants
WM_SYSCOMMAND : Integer = #112;
WM_LBUTTONUP : Integer = #202;
MOUSE_MOVE : Integer = #f012;
SC_MOVE : Integer = #f010;
vars
begin

// This method allows for the movement of a form by directly accessing windows - the same as would happen
// if you clicked and dragged the standard windows blue tool bar at the top of each form. This method gives
// the ability to suppress the windows blue toolbar and use your own layout instead. If you turn off the
// pc's control panel setting to 'show windows while dragging', the movement will show a phantom rectangle
// being moved around the screen.

// To set up the external function do the following:
// 1) Go to External Function browser
// 2) Add library - user32
// 3) Add external function - name = sendMessage
// entry point = sendMessage
// library = user32
// 4) Define sendMessage signature as follows:
// sendMessage(hwnd:Integer;msg:Integer;lParam:Integer;wParam:Integer):Integer is SendMessageA in user32

call sendMessage(hwnd,WM_LBUTTONUP,0,0);
call sendMessage(hwnd,WM_SYSCOMMAND,MOUSE_MOVE,0);
end;

setup the external function as stated in the above method, and then on the mouseDown event of your new title bar (and any labels etc that are sitting on the title bar) do the following:

moveForm(self.hwnd);

Thats it. This works very well.

A web site you might like to visit is: http://skyscraper.fortunecity.com/trans ... index.html
This site lists out windows api functions in various sort sequences (name, category, callback etc). Good quick online reference that also lets you download the site in zipped form.

Cheers, Sean

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Two Windows API Questions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:46 am

by Carl Ranson >> Wed, 15 Dec 1999 23:30:39 GMT

The shadow effect is tricky but could be done. Probably not worth attempting in Jade as it's support for bitmaps is not terribly flash. I would use Delphi and call it from Jade.

It would probably include the following steps.

1. Hide your form.
2. BitBlit from the screen device context. The region you need to copy is the size of your form plus the size of the shadow area. This gives you a bitmap of the area partially or fully obscured by your form.
3. Create a monocrome bitmap for transparency. This would be a solid block for the rect that is your form plus a checkerboard pattern for the shadow (this would give the stuff underneath a half tone apperance)
4. Do a transparent blit for the mask and the bitmap you got at stage 2 (draws the shadow region).
5. BitBlit your form and the mask (draws your form in)
6. bitBlit the whole thing back to the screen.

Thats the approach I would try to start with. There's a fair bit of detail to fill in. (scared yet)
Microsoft have a lot of info available online at www.msdn.microsoft.com about this sort of thing.

Regards,
Carl

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Two Windows API Questions

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:46 am

by Torrie Moore >> Thu, 16 Dec 1999 5:40:50 GMT

I would also use Delphi or C to create the shadow, but would take a slightly different approach.
If you create a transparent window (available with CreateWindowEx in the win API) you can paint a checkerboard pattern on the transparent form which would give a see through shadow. You could then position and size this window behind your Jade window but off set by the amount of shadow required. (set the parent of the Jade window to this form) You would need to synchronize the transparent form with the Jade form so when the Jade form was moved the transparent form would also move. Again a lot of detail is not included.


Torrie Moore


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 23 guests