Results 1 to 11 of 11

Thread: How do I make a STATIC type window not ignore the mouse?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    How do I make a STATIC type window not ignore the mouse?

    I used CreateWindowEX, and for the Class Parameter, I put in "STATIC". This creates a window with nothing in it, but the label containing the text for that window ("Test Window" in this case). Now the problem is that the STATIC window, behaves as if it's not even there. If my main VB6 form is below it because this new window is attached to my main window as its child (forcing it to always be above the main form window), my clicks go right "through" the this upper STATIC window, and will click a button on my form below! I thought a STATIC window was basically a regular form type window with no controls placed on it or code typed in it, where clicks would be captured by it, but have no effect on it. However they are not captured by it, but go right on through it to the window below (in this case, my program's main form window). Why is this happening? How do I get my created STATIC window to capture any mouse clicks that happen over it?

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How do I make a STATIC type window not ignore the mouse?

    Did you enable the window? Disabled windows receive no mouse events: Try EnableWindow API

    You can verify this with a picbox added to your form. Disable the picbox & in the form's click event, display a msgbox. When you click on the picbox, you should get the msgbox

    Edited: EnableWindow may not work either. Per MSDN
    Applications often use static controls to label other controls or to separate a group of controls. Although static controls are child windows, they cannot be selected. Therefore, they cannot receive the keyboard focus and cannot have a keyboard interface. A static control that has the SS_NOTIFY style receives mouse input, notifying the parent window when the user clicks or double clicks the control. Static controls belong to the STATIC window class.
    If EnableWindow fails, you will need to ensure you included the SS_NOTIFY style when you create the Static window & then subclass its container to look for WM_Command messages. Be sure to give the Static window a control ID (the hMenu parameter of CreateWindowEx) when it is created so you can refer to it when the WM_Command message is received.
    Last edited by LaVolpe; Dec 20th, 2014 at 07:51 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I make a STATIC type window not ignore the mouse?

    Quote Originally Posted by LaVolpe View Post
    Did you enable the window? Disabled windows receive no mouse events: Try EnableWindow API

    You can verify this with a picbox added to your form. Disable the picbox & in the form's click event, display a msgbox. When you click on the picbox, you should get the msgbox

    Edited: EnableWindow may not work either. Per MSDN

    If EnableWindow fails, you will need to ensure you included the SS_NOTIFY style when you create the Static window & then subclass its container to look for WM_Command messages. Be sure to give the Static window a control ID (the hMenu parameter of CreateWindowEx) when it is created so you can refer to it when the WM_Command message is received.
    Thanks for the info. That SS_NOTIFY, now causes it to take mouse clicks, so that I can actually click it, and not have the mouse click go right through it and affect a window below it. But I still can't drag it. Yes there's a title bar, and an X button in the upper right of the window to close it. But clicking that X button does not close it, and clicking and dragging on the title bar does not move the window.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How do I make a STATIC type window not ignore the mouse?

    Static controls are not meant to be used for input. VB equivalent is a Label control. I'd think that if SendMessage with WM_NCLButtonDown & HTCAPTION option won't work, you may have to do it manually via the MoveWindow or SetWindowPos APIs. Just a thought, why not use an Edit control instead, locked to prevent editing? You can flag it as a "label" if it's important?

    FYI: This info from MSDN should explain why you don't get mouse clicks without the SS_NOTIFY style. The article is really old, dates back to 1992 & I think it was written before the SS_NOTIFY style, but besides being a bit outdated, good background info. My gut feeling without running tests myself, is that HTTransparent is being returned when the mouse is 'clicked' on the non-client area (titlebar).
    Static controls might be called "no input controls" because they accept no input from the user. If the user moves the mouse over a static control, Windows sends the control a WM_NCHITTEST message. The static control returns an HTTRANSPARENT value to Windows, which then sends the WM_NCHITTEST message to the static control's parent window. As a result of this processing, the parent window of the static control receives all mouse events.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I make a STATIC type window not ignore the mouse?

    I'd still think that if it is configured using the style parameter, to have a titlebar (which is a draggable part of most windows), that it should make the static window dragable. How do I make it draggable?

    And what is the window class that is equivalent to a "blank form" (where controls have yet to be added), if it isn't the "STATIC" class?

    I'm looking at http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx and the available Window classes shown here are:
    Button
    ComboBox
    Edit
    ListBox
    MDIClient
    ScrollBar
    Static

    It then goes on to show some additional classes that only the system is supposed to use:
    ComboLBox
    DDEMLEvent
    Message
    #32768
    #32769
    #32770
    #32771
    #32772

    And yes those numbers with number signs are literal strings like "#32768". Now while I have tried using "#32770" in my program to create a dialog box class window (as it says in MSDN "#32770 The class for a dialog box."), and this class of window DOES behave the way I want, I'm not sure if I'm really supposed to be doing that, because the MSDN webpage clearly states that these are for use only by the system. Could using it like this cause any problems?

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How do I make a STATIC type window not ignore the mouse?

    A class is simply a type of window. The ones shown are available to everyone that come with their own default message handlers (window procedures). The VB form is a class also. VB uses run-time and design-time classes. Google a bit for ThunderRT6Main.

    Whether you included window styles that show a titlebar or not means nothing if the class/window's default window procedure does not handle those messages or, in this case, may ignore them.

    I'm pretty familiar with most of those numbered classes. I've used the menu class quite a bit in the past, when designing my own custom menu systems. FYI: Dialog classes (windows) have their own set of messages and APIs too. They are designed to be created from other APIs, not CreateWindowEx.

    None of the above answers your question unfortunately. I think you'll want to spend some significant time researching
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How do I make a STATIC type window not ignore the mouse?

    P.S. If you want to have fun & lots of work, you can create your window class, say ClassOfBen. You would have to create your own window procedure for it and then handle every message windows sends to it. When I say lots of work, it is. You have to draw everything yourself, as needed and decide which & how each of the 100's of messages that can come to your window class will be handled. See the API RegisterClassEx
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I make a STATIC type window not ignore the mouse?

    Quote Originally Posted by LaVolpe View Post
    P.S. If you want to have fun & lots of work, you can create your window class, say ClassOfBen. You would have to create your own window procedure for it and then handle every message windows sends to it. When I say lots of work, it is. You have to draw everything yourself, as needed and decide which & how each of the 100's of messages that can come to your window class will be handled. See the API RegisterClassEx

    Is there a Window class name that corresponds to a VB form type window? Can I just use the string "Form" in the parameter for window class, in the CreateWindowEx function? If not, is there some other way to do this? I was hoping for a way to get to a blank form, not tied to any already existing in my project.
    I can do Dim MyForm as Form (which simply creates a placeholder Form variable that I can later use with Set MyForm = New Form1), but I can't do Dim MyForm as New Form. There is no way to create a generic "Form" using VB6 code alone, as you have to do Dim Myform as New Form1, but then that ties it into Form1, not a generic blank form, that I could later populate programmaticly with controls. That's when I turned to the CreateWindowEx API function, and I THOUGHT that "STATIC" was the official API name for "Form". But it appears that it's not. And I am hoping somebody here knows how to use CreateWindowEx to spawn a generic Form.

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How do I make a STATIC type window not ignore the mouse?

    A VB form is a class. I'd think it is registered as soon as you start VB. However, as I mentioned earlier, I believe there is a run-time & design-time version & if not, the design-time may handle messages differently than the design-time. I wouldn't suggest going that route unless you know for sure that the run-time version (is it ThunderRT6Main?) is registered/available during IDE. If it is, you can try to use CreateWindowEx with "ThunderRT6Main" vs "Static" for example.

    But here's a question? Why not just use a blank form? It doesn't have to have any controls on it. Just a blank/template you have in your project? A blank form would be virtually identical to "New Form", no?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I make a STATIC type window not ignore the mouse?

    Quote Originally Posted by LaVolpe View Post
    A VB form is a class. I'd think it is registered as soon as you start VB. However, as I mentioned earlier, I believe there is a run-time & design-time version & if not, the design-time may handle messages differently than the design-time. I wouldn't suggest going that route unless you know for sure that the run-time version (is it ThunderRT6Main?) is registered/available during IDE. If it is, you can try to use CreateWindowEx with "ThunderRT6Main" vs "Static" for example.

    But here's a question? Why not just use a blank form? It doesn't have to have any controls on it. Just a blank/template you have in your project? A blank form would be virtually identical to "New Form", no?
    I don't think it's ThunderRT6Main, because I tried:
    Code:
    CreateWindowEx 0, "ThunderRT6Main", "test", &H10000000, 0, 0, 200, 200, Form1.hWnd, 0, 0, 0&
    and it didn't work.

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How do I make a STATIC type window not ignore the mouse?

    Quote Originally Posted by Ben321 View Post
    I don't think it's ThunderRT6Main, because I tried:
    Code:
    CreateWindowEx 0, "ThunderRT6Main", "test", &H10000000, 0, 0, 200, 200, Form1.hWnd, 0, 0, 0&
    and it didn't work.
    Might want to try it again, with a compiled exe running somewhere. Maybe that class isn't available unless a compiled vb exe is actually loaded? Also verify that that is the name of the class. You can use GetClassName API from a compiled project. If that does work, I don't see what good this will do you during IDE?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

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



Click Here to Expand Forum to Full Width