Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: never lose focus

  1. #11
    Variable Bitrate
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    307
    hihi, think I adviced you to use this a while ago...

    oops my mistake, tried to help andrew chappell with this solution , just looked it up :New MP3 Car Software in VB6

    but that IS what I'm using, problem is that when vblink or winamp has the focus, both my app AND WinAmp react to the keystrokes, I only want my app to react, WinAmp shouldn't
    If at first you don't succeed.........
    destroy all evidence you tried

    for info on t6369c LCD or Presslab's powersupply check:
    http://www.namms.tk <=updated!!

  2. #12
    Newbie
    Join Date
    Jun 2002
    Location
    Norfolk,UK
    Posts
    45
    @marsjell

    Here's the C++ code that I'm using:

    I have two message procs in one Called WndProc which handles messages from my windows and one called WinampWndProc that I use to grab the winamp messages.

    when the program starts (DLL init's) I repace winamps WndProc with my own:

    In this case I have the hwnd (as it's a DLL plugin), I guess that if you want to do this then it would have to be a DLL.

    //Get the original proc address
    lpWndProcOld = (void *) GetWindowLong(plugin.hwndParent,GWL_WNDPROC);
    //Set the address where winamp's win proc is
    SetWindowLong(plugin.hwndParent,GWL_WNDPROC,(long) WinampWndProc);


    so in WinampWndProc:

    LRESULT CALLBACK WinampWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    if(iwant the message)
    do something with it
    else
    return CallWindowProc((long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long))lpWndProcOld,hwnd,message,wParam,lParam) ;
    }

    Anyway that's the C++ version, perhaps someone could post the VB equivalent?

    ~MGP3Car

  3. #13
    Variable Bitrate
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    307
    Hi,

    so I'm guessing that "GWL_WNDPROC" determines which event to capture?
    what value should this have?
    If at first you don't succeed.........
    destroy all evidence you tried

    for info on t6369c LCD or Presslab's powersupply check:
    http://www.namms.tk <=updated!!

  4. #14
    Newbie
    Join Date
    Jun 2002
    Location
    Norfolk,UK
    Posts
    45
    Sort of (but not quite) GetWindowLong(plugin.hwndParent,GWL_WNDPROC); gets the address of the wndproc, this is the proc that handles all messages (~events) for the window refered to by hwndParent.

    So by setting that value to your own wndproc, (using SetWindowLong) your proc will get the messages, not the original winamp one.

    But if you get a message in your proc that you don't want, then you can still pass it back to the real winamp one using CallWindowProc with the lpWndProcOld that you got with GetWindowLong.

  5. #15
    Variable Bitrate
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    307
    yes I understand, but I need to know which wndproc to alter therefor GWL_WNDPROC needs a value. (I think)

    I do know that VB gives me an error if I do not assign a value to GWL_WNDPROC, or am I doing something wrong?
    If at first you don't succeed.........
    destroy all evidence you tried

    for info on t6369c LCD or Presslab's powersupply check:
    http://www.namms.tk <=updated!!

  6. #16
    Newbie
    Join Date
    Jun 2002
    Location
    Norfolk,UK
    Posts
    45
    Ahhhhh....... I see, a bit of confusion between the #defined value in c++ and what I guess VB would think is an implicit variable.
    what you need is the value that GWL_WNDPROC is #defined to, no worries I'll check the value when I get home tonight (or you could track down the appropriate *.h file).
    ~MGP3Car

  7. #17
    Newbie
    Join Date
    Jun 2002
    Location
    Norfolk,UK
    Posts
    45

    Nearly forgot, OK did forget!

    #define GWL_WNDPROC (-4)

    Hope this helps

  8. #18
    Variable Bitrate
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    307


    hmmm allready tried that value but didn't work...
    I solved it by simple minimizing all active windows every 30 sec. not really the way I like it, but it works....


    thanks for your efford!
    If at first you don't succeed.........
    destroy all evidence you tried

    for info on t6369c LCD or Presslab's powersupply check:
    http://www.namms.tk <=updated!!

  9. #19
    Low Bitrate
    Join Date
    Apr 2002
    Location
    Bay Area, California, USA
    Posts
    64
    I don't know enough VB (if any at all =), but when I saw this thread I imagined you could solve your problem with an AutoIt script like this one:

    Start:
    IfWinNotActive,Title of your window,,WinActivate,Title of your Window
    Goto,Start

    I know it's a loop just like the one you wrote now (minimize all active windows), but this kind of script barely uses any resources. If you feel like trying it, here's the link:

    http://www.hiddensoft.com/AutoIt/

    But if you don't want to download the whole thing I could send you/post a compiled exe.

    Let me know.

  10. #20
    FLAC
    Join Date
    Aug 1999
    Location
    Upper Marlboro, MD 20772
    Posts
    1,311
    ok enough of this thread....here is what u need to do. Declare an external API call...function name is BringWindowToTop it is as follows in VB.

    Declare Function BringWindowToTop Lib "user32" Alias "BringWindowToTop" (ByVal hwnd As Long) As Long

    The BringWindowToTop function brings the specified window to the top of the Z order. If the window is a top-level window, it is activated. If the window is a child window, the top-level parent window associated with the child window is activated.

    NOTE: keep in mind that hwnd is the handle to the window or control u want to bring to the top. So u have two choices here. You can call this once or use your timmer and trigger this every X amount of seconds or minutes or which ever u see fit....

    Also look at SetWindowPos...go to http://www.allapi.net/
    PS. i hope this helps. Ofcourse there are other ways too....
    abcd-1
    Author of CobraI,II,III and now CobraIV.
    You can contact me on AOL instant messenger....nick is cenwesi or cenwesi3

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •