Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetWindowPos 2

Status
Not open for further replies.

mattKnight

Programmer
May 10, 2002
6,225
GB
Its been a while!

Quick one

I have a form (which amongst some other code), has the following

Code:
SetWindowPos Me.hwnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE

I have a button bar (MS Common Controls) and when the form is shown (and by using SetWindowPos to force "always on top"), the buttons don't receive clicks. Commenting out the SetWindowPos line restores full operation. The form doesn't loose focus (I assume) as the LostFocus event doesn't fire

Why?





Take Care

Matt
I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.
 
Thanks for the link

The behaviour doesn't change (i.e. I still can't click buttons) regardless of whether the program runs in the IDE or as a compiled exe

Take Care

Matt
I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.
 
I am trying to simulate what you have.

>MS Common Controls
What version?

>I have a button bar
Do you mean a ToolBar?

If it is a ToolBar, are the buttons ToolBar buttons or Command buttons placed inside it?

So far in my trials using MS Common Controls v5 & 6 I have no problems; click events for ToolBar Buttons and embedded Command buttons are both firing.

note:
Using SetWindowPos Me.hwnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE
resets the windows size to its minimum; when SWP_NOMOVE Or SWP_NOSIZE is used the window size is not changed.

 
> What version?

Version 6.0

Interestingly, the Common Controls 1 OCX is tagged as being SP6 while the 2 and 3 ones are tagged as SP4.

>Do you mean a ToolBar?

Yes, I do!


>If it is a ToolBar, are the buttons ToolBar buttons or Command buttons placed inside it?

I am using ToolBar Buttons. However, a simple command button on the form also doesn't work.


>Using SetWindowPos Me.hwnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE
resets the windows size to its minimum; when SWP_NOMOVE Or SWP_NOSIZE is used the window size is not changed.

Again, the for displays at the correct size, however adding the SWP_NOSIZE flag to the SetWinodwPos call solves the issue.



Take Care

Matt
I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.
 
>So the buttons are firing now

The issue wasn't that the event wasn't firing, but that the button wasn't depressing when clicked (and hence no event)

I'd guess that the SetWindowPos call was resizing the fomr to a 0 by 0 size and then I was clicking on a vestige of the form, rather than the form itself. I didn't mention, because I didn't think it relevant, I am fading teh form in and out using Setlayerattribute - and it seems that this is causing the vestige,

Take Care

Matt
I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.
 
>SetWindowPos call was resizing the fomr to a 0 by 0 size...

You can avoid this by specifying the SWP_NOSIZE flag along with SWP_NOMOVE.

[tt]SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE[/tt]

The value of SWP_NOSIZE is 1.
 
>Hyp, like suggested in my first post!

hence the star!

Take Care

Matt
I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top