Lufia_Maxim

Member

Total Posts: 276
Online Status: Offline
Tue Feb 24 22:05:23 EST 2009

I know there's some prorammers among this community, and I spend most of my day on here, so I figured I'd ask here. (smiley)

Basically, what I'm trying to do is get a window form to emualte the "Stay on Top" function many windows already have.

Doing a quick google search, there seems to be some code floating around to do just that.


Now, before you read on, keep in mind I'm stil fresh in college for studying VB, and am therefore still fairly noobish. Please forgive any stupid mistakes you find and help increase my knowledge.

The same sites also provided the code to initiate this stay on top feature, and I figured the most logical place to put it would be in the Form's load code part:

Line 5 is what the site I got the code from suggested, but said I could also use line 6's method and it'd be fine.

Problem: Both lines give the "hWnd is not a member of ___"

Help? :/



Cyberkilla

Admin

Total Posts: 5,844
Online Status: Offline
Wed Feb 25 7:34:22 EST 2009

I found this site: http://www.developerfusion.com/code/662/always-on-top/

I can't pretend to know everything about VB. I haven't used it for years.

However, it may be the case that you can't know the handle of the form until it has been created.

Look at this example I found:

' ---------------------------------------------------
' FORM frmMapSearch
' ---------------------------------------------------
Private Sub Form_Activate()
  MakeTopMost Me.hwnd
End Sub
The result is that when the form is drawn screen the Sub MakeTopMost will be called and then it will act as a modal form.


He is using a different event callback.



Invisible War ][
Edited 2 time(s). Last edited by Cyberkilla @ Wed Feb 25 7:37:17 EST 2009

Lufia_Maxim

Member

Total Posts: 276
Online Status: Offline
Fri Feb 27 18:52:08 EST 2009

I still haven't figured this out... if anyone has any more suggestions..


CK, I tried putting the code in a button click event but still the asme error.



Cyberkilla

Admin

Total Posts: 5,844
Online Status: Offline
Fri Feb 27 20:01:33 EST 2009

Are you sure you are pa**ing it the right handle?

Invisible War ][

Lufia_Maxim

Member

Total Posts: 276
Online Status: Offline
Fri Feb 27 20:54:49 EST 2009

I'm not too familiar with the terminology.

Handle = ?



Cyberkilla

Admin

Total Posts: 5,844
Online Status: Offline
Sat Feb 28 7:12:18 EST 2009

Quote from Lufia_Maxim
I'm not too familiar with the terminology.

Handle = ?


Every  control in VB has a window handle, not just the form. If you are putting the code in the wrong place, you could be pa**ing it the handle of a button, not the form.

Quote from Google
A window handle (usually shortened to hWnd) is a unique identifer that Windows a**igns to each window created. By window in this case we are referring to everything from command buttons and textboxes, to dialog boxes and full windows.

The window handle is used in APIs as the sole method of identifying a window. It is a Long (4 byte) value and you can get the handle for forms and almost all controls in Visual Basic by using the .hWnd property.



Invisible War ][
Edited 1 time(s). Last edited by Cyberkilla @ Sat Feb 28 7:13:49 EST 2009