CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2008
    Posts
    214

    C++ Winapi - RegisterWindowMessage

    I am trying to register:

    Code:
    UINT WM_USER_MOUSEMOVE = RegisterWindowMessage("uSer-mOuSeMoVe-mOuSeHoOk");
    and using it here:

    Code:
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message)                  /* handle the messages */
        {
        case WM_USER_MOUSEMOVE:
        {
    and get error:

    Code:
    error: `WM_USER_MOUSEMOVE' cannot appear in a constant-expression|
    when multiple examples say to use it like this. Any ideas? thanks.

  2. #2
    Join Date
    May 2007
    Posts
    437

    Re: C++ Winapi - RegisterWindowMessage

    Quote Originally Posted by zaryk View Post
    I am trying to register:

    Code:
    UINT WM_USER_MOUSEMOVE = RegisterWindowMessage("uSer-mOuSeMoVe-mOuSeHoOk");
    and using it here:

    Code:
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message)                  /* handle the messages */
        {
        case WM_USER_MOUSEMOVE:
        {
    and get error:

    Code:
    error: `WM_USER_MOUSEMOVE' cannot appear in a constant-expression|
    when multiple examples say to use it like this. Any ideas? thanks.
    You can not use the registered window message in Swith case. if you want to use in callback, compare with if condition..

    for more please look at this thread

    go through this thread, it will be clear
    http://www.codeguru.com/forum/showthread.php?t=343079
    ashu
    always use code tag

  3. #3
    Join Date
    Apr 2008
    Posts
    214

    Re: C++ Winapi - RegisterWindowMessage

    Well, thats kinda lame. If message is UINT, and RegisterWindowMessage is UINT....I would think it would work in switch/case statement. Oh well. Thanks!

  4. #4
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: C++ Winapi - RegisterWindowMessage

    switch' case statement can only take CONSTANT INTEGERS!
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

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

Featured