Author | Message | Time |
---|---|---|
Networks | How do you impliement a "stay on top" function in a VB6 Application? | April 9, 2004, 7:12 PM |
K | You will need to call SetWindowPos() with the HWND_TOPMOST parameter. Edit: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/ WindowReference/WindowFunctions/SetWindowPos.asp | April 9, 2004, 7:31 PM |
Grok | [code]Private Function StayOnTop(ByRef TopPerson As CPerson, ByRef BottomPerson As CPerson) As True Do While TopPerson.Altitude <= BottomPerson.Altitude TopPerson.Altitude = TopPerson.Altitude + 1 If BottomPerson.Slap(TopPerson) = REAL_HARD Then StayOnTop = False Exit Function End If Loop StayOnTop = True End Function[/code] Hope this helps. | April 9, 2004, 7:34 PM |
Networks | Usage? And there is a syntax error Grok. | April 9, 2004, 9:44 PM |
Spht | [quote author=Networks link=board=31;threadid=6224;start=0#msg54289 date=1081547059] Usage? And there is a syntax error Grok. [/quote] StayOnTop(Grok, Networks) | April 9, 2004, 9:49 PM |
Networks | I am little confused I talking about windows here. | April 9, 2004, 9:51 PM |
iago | grok's response was a joke. Read K's, it explains what you need to know. | April 9, 2004, 9:52 PM |
K | [quote author=iago link=board=31;threadid=6224;start=0#msg54292 date=1081547565] grok's response was a joke. Read K's, it explains what you need to know. [/quote] Although if you couldn't figure out that Grok's was a joke, good luck implementing the simple api call ::) | April 9, 2004, 11:01 PM |
Eli_1 | [quote author=Networks link=board=31;threadid=6224;start=0#msg54289 date=1081547059] Usage? And there is a syntax error Grok. [/quote] More proof that people don't actually read the code the copy and paste. | April 9, 2004, 11:34 PM |
Newby | [quote author=Networks link=board=31;threadid=6224;start=0#msg54289 date=1081547059] Usage? And there is a syntax error Grok. [/quote] Define REAL_HARD as "With Blood" ;) EDIT -- I totally agree. That is pathetic he didn't catch on to that. | April 10, 2004, 12:49 AM |
Eli_1 | [quote author=Newby link=board=31;threadid=6224;start=0#msg54304 date=1081558196] [quote author=Networks link=board=31;threadid=6224;start=0#msg54289 date=1081547059] Usage? And there is a syntax error Grok. [/quote] Define REAL_HARD as "With Blood" ;) EDIT -- I totally agree. That is pathetic he didn't catch on to that. [/quote] [code] Const REAL_HARD as String = "With Blood" '// * [/code] ;D | April 11, 2004, 1:14 AM |
Fr0z3N | [code] '************************************** 'Windows API/Global Declarations for 'Always On Top '************************************** Declare Function SetWindowPos Lib "user32" _ (ByVal hwnd As Long, _ ByVal hWndInsertAfter As Long, _ ByVal X As Long, _ ByVal Y As Long, _ ByVal cx As Long, _ ByVal cy As Long, _ ByVal wFlags As Long) As Long Public Sub AlwaysOnTop(myfrm As Form, SetOnTop As Boolean) If SetOnTop Then lFlag = HWND_TOPMOST Else lFlag = HWND_NOTOPMOST End If SetWindowPos myfrm.hwnd, lFlag, _ myfrm.Left / Screen.TwipsPerPixelX, _ myfrm.Top / Screen.TwipsPerPixelY, _ myfrm.Width / Screen.TwipsPerPixelX, _ myfrm.Height / Screen.TwipsPerPixelY, _ SWP_NOACTIVATE Or SWP_SHOWWINDOW End Sub 'Well, if your for example in a form cal ' led 'Form1' then you'd simply type: AlwaysOnTop Form1, True [/code] | April 11, 2004, 4:03 AM |
LoRd | [quote author=Fr0z3N link=board=31;threadid=6224;start=0#msg54512 date=1081656225] [code] '************************************** 'Windows API/Global Declarations for 'Always On Top '************************************** Declare Function SetWindowPos Lib "user32" _ (ByVal hwnd As Long, _ ByVal hWndInsertAfter As Long, _ ByVal X As Long, _ ByVal Y As Long, _ ByVal cx As Long, _ ByVal cy As Long, _ ByVal wFlags As Long) As Long Public Sub AlwaysOnTop(myfrm As Form, SetOnTop As Boolean) If SetOnTop Then lFlag = HWND_TOPMOST Else lFlag = HWND_NOTOPMOST End If SetWindowPos myfrm.hwnd, lFlag, _ myfrm.Left / Screen.TwipsPerPixelX, _ myfrm.Top / Screen.TwipsPerPixelY, _ myfrm.Width / Screen.TwipsPerPixelX, _ myfrm.Height / Screen.TwipsPerPixelY, _ SWP_NOACTIVATE Or SWP_SHOWWINDOW End Sub 'Well, if your for example in a form cal ' led 'Form1' then you'd simply type: AlwaysOnTop Form1, True [/code] [/quote] I saw something nearly identical to that on pscode, but I'm sure it's just a coincidence. ;) | April 11, 2004, 10:14 AM |
Spht | [quote author=LoRd[nK] link=board=31;threadid=6224;start=0#msg54534 date=1081678482] I saw something nearly identical to that on pscode, but I'm sure it's just a coincidence. ;) [/quote] He never claimed he wrote it, so you could be right. | April 11, 2004, 4:08 PM |
iago | Also, how different can stay-on-top code BE? I mean, besides Grok's :) | April 11, 2004, 6:08 PM |
Tuberload | Why re-invent the wheel? Give credit where it is due, and move on. | April 11, 2004, 7:08 PM |
Fr0z3N | I didn't write it, I got it off pscode. | April 12, 2004, 2:36 AM |
Dyndrilliac | Code doesn't work, gives a Type Mismatch RunTime error for me. | April 12, 2004, 3:08 AM |
Networks | [code] '************************************** 'Windows API/Global Declarations for 'Always On Top '************************************** Declare Function SetWindowPos Lib "user32" _ (ByVal hwnd As Long, _ ByVal hWndInsertAfter As Long, _ ByVal X As Long, _ ByVal Y As Long, _ ByVal cx As Long, _ ByVal cy As Long, _ ByVal wFlags As Long) As Long Public Sub AlwaysOnTop(myfrm As Form, SetOnTop As Boolean) If SetOnTop Then lFlag = HWND_TOPMOST Else lFlag = HWND_NOTOPMOST End If SetWindowPos myfrm.hwnd, lFlag, _ myfrm.Left / Screen.TwipsPerPixelX, _ myfrm.Top / Screen.TwipsPerPixelY, _ myfrm.Width / Screen.TwipsPerPixelX, _ myfrm.Height / Screen.TwipsPerPixelY, _ SWP_NOACTIVATE Or SWP_SHOWWINDOW End Sub 'Well, if your for example in a form cal ' led 'Form1' then you'd simply type: AlwaysOnTop Form1, True [/code] [code]SetWindowPos myfrm.hwnd, lFlag, _[/code] had two lines underneath it making it not work this is the correct one ^ | April 12, 2004, 3:29 AM |
Grok | Way too much code for just TOPMOST. Send a message instead? | April 12, 2004, 4:05 AM |
Adron | [quote author=Tuberload link=board=31;threadid=6224;start=15#msg54578 date=1081710489] Why re-invent the wheel? Give credit where it is due, and move on. [/quote] I mostly give "credit" when I take code from a site and post it here. The most important reason isn't to credit them though, but in case of: [quote author=Dyndrilliac link=board=31;threadid=6224;start=15#msg54671 date=1081739332] Code doesn't work, gives a Type Mismatch RunTime error for me. [/quote] So, that way they know that I'm not to be blamed if the code doesn't work on all computers.... :P | April 12, 2004, 10:31 AM |
Tuberload | [quote author=Adron link=board=31;threadid=6224;start=15#msg54731 date=1081765914] [quote author=Tuberload link=board=31;threadid=6224;start=15#msg54578 date=1081710489] Why re-invent the wheel? Give credit where it is due, and move on. [/quote] I mostly give "credit" when I take code from a site and post it here. The most important reason isn't to credit them though, but in case of: [quote author=Dyndrilliac link=board=31;threadid=6224;start=15#msg54671 date=1081739332] Code doesn't work, gives a Type Mismatch RunTime error for me. [/quote] So, that way they know that I'm not to be blamed if the code doesn't work on all computers.... :P [/quote] Never thought of it like that. Hey their not bugs their features, remember. ;) | April 12, 2004, 2:43 PM |
Adron | [quote author=Tuberload link=board=31;threadid=6224;start=15#msg54751 date=1081781036] [quote author=Adron link=board=31;threadid=6224;start=15#msg54731 date=1081765914] So, that way they know that I'm not to be blamed if the code doesn't work on all computers.... :P [/quote] Never thought of it like that. Hey their not bugs their features, remember. ;) [/quote] Perhaps it's a difference in attitude... I like my code. It's mostly just the way I want it, and it's good. I wouldn't want to take someone else's code and put my name on it, because then their lousy code could put a smear on my name. And yes, sometimes my code has more features than I intended, but it's my code, and I'm proud of it! :P | April 12, 2004, 3:36 PM |
Tuberload | [quote author=Adron link=board=31;threadid=6224;start=15#msg54761 date=1081784219] [quote author=Tuberload link=board=31;threadid=6224;start=15#msg54751 date=1081781036] [quote author=Adron link=board=31;threadid=6224;start=15#msg54731 date=1081765914] So, that way they know that I'm not to be blamed if the code doesn't work on all computers.... :P [/quote] Never thought of it like that. Hey their not bugs their features, remember. ;) [/quote] Perhaps it's a difference in attitude... I like my code. It's mostly just the way I want it, and it's good. I wouldn't want to take someone else's code and put my name on it, because then their lousy code could put a smear on my name. And yes, sometimes my code has more features than I intended, but it's my code, and I'm proud of it! :P [/quote] I have my own style, well an adopted style anyways. I never directly use anyone's code, if I do I re-write it to satisfy my needs, and then give credit to the original author. It's definitely my code, but I wouldn't go as far as to say it's any good. :) I'll leave that one up to the critics. Kp does an excellent job of pointing out improvements for me. | April 12, 2004, 8:21 PM |
Grok | I use other people's code "snippets" all the time without giving credit, if it's something I could've done just by sitting down and doing it. If it's something that took a significant investment in time or skill, then I'll give credit in my source code. If I purchase license to use code in libraries (such as ActiveX controls), or in source form, I never give credit and don't feel any is due. | April 12, 2004, 8:32 PM |
Tuberload | [quote author=Grok link=board=31;threadid=6224;start=15#msg54818 date=1081801957] I use other people's code "snippets" all the time without giving credit, if it's something I could've done just by sitting down and doing it. If it's something that took a significant investment in time or skill, then I'll give credit in my source code. If I purchase license to use code in libraries (such as ActiveX controls), or in source form, I never give credit and don't feel any is due. [/quote] I think that's a very good point. Simple code snippets, as you pointed out, are not original in my opinion so why give credit. I think it is the design and logic behind certain pieces of code that deserves credit. [Edit: grammar] | April 12, 2004, 9:45 PM |
Adron | [quote author=Tuberload link=board=31;threadid=6224;start=15#msg54840 date=1081806333] I think that's a very good point. Simple code snippets, as you pointed out, are not original in my opinion so why give credit. I think it is the design and logic behind certain pieces of code that deserves credit. [Edit: grammar] [/quote] Bugs is what might make them unique and original... :P | April 12, 2004, 11:58 PM |
Tuberload | [quote author=Adron link=board=31;threadid=6224;start=15#msg54857 date=1081814317] [quote author=Tuberload link=board=31;threadid=6224;start=15#msg54840 date=1081806333] I think that's a very good point. Simple code snippets, as you pointed out, are not original in my opinion so why give credit. I think it is the design and logic behind certain pieces of code that deserves credit. [Edit: grammar] [/quote] Bugs is what might make them unique and original... :P [/quote] Then I will fix them, and notify the original author. From that point on he will have to give me credit. :) | April 13, 2004, 12:05 AM |
Networks | If anyone cares um.. The code fr0z3n provided didn't work any other help? | April 13, 2004, 12:33 AM |
Tuberload | [quote author=Networks link=board=31;threadid=6224;start=15#msg54865 date=1081816431] If anyone cares um.. The code fr0z3n provided didn't work any other help? [/quote] https://davnit.net/bnet/vL/phpbbs/index.php?board=2;action=display;threadid=6269 This thread might be able to help you find what you are looking for. | April 13, 2004, 12:39 AM |
Eli_1 | [quote author=Networks link=board=31;threadid=6224;start=15#msg54865 date=1081816431] If anyone cares um.. The code fr0z3n provided didn't work any other help? [/quote] Here: [code] Const HWND_TOPMOST = -1 Const HWND_NOTOPMOST = -2 Const SWP_NOSIZE = &H1 Const SWP_NOMOVE = &H2 Const SWP_NOACTIVATE = &H10 Const SWP_SHOWWINDOW = &H40 Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) Const HWND_WILLUNOTICE as String = "t3h ub3r h4x0r" Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long Public Sub SetTopMost(TheForm as Form) SetWindowText TheForm.hWnd, HWND_WILLUNOTICE SetWindowPos TheForm.hWnd, HWND_TOPMOST, 0, 0, _ 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW _ Or SWP_NOMOVE Or SWP_NOSIZE End Sub [/code] | April 13, 2004, 12:43 AM |