Tabbed Windows with MDI?

This is a discussion on Tabbed Windows with MDI? within the Windows Programming forums, part of the Platform Specific Boards category; hey, i was checking out the messages for MDI windows on the MSDN website ( http://msdn.microsoft.com/library/de...tinterface.asp ) and i wasn't ...

  1. #1
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378

    Tabbed Windows with MDI?

    hey, i was checking out the messages for MDI windows on the MSDN website ( http://msdn.microsoft.com/library/de...tinterface.asp ) and i wasn't seeing message that will allow me to make the windows tabbed. so i was wonder if it could be done? and if anyone has a reference or knowledge on how then it would be greatly appreciated thanks
    Registered Linux User #380033. Be counted: http://counter.li.org

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    Awesome, thank you.


    Another problem i'm having is with this code:
    Code:
    				default:
    				{
    					if(LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
    					{
    						DefFrameProc(hwnd, g_hMDIClient, WM_COMMAND, wParam, lParam);
    					}
    					else 
    					{
    						HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0);
    						if(hChild)
    						{
    							SendMessage(hChild, WM_COMMAND, wParam, lParam);
    						}
    					}
    				}
    its producing an error in both Dev-C++ and MSVC++ 6
    Dev-C++:
    WinTest02.c:382: error: syntax error before ';' token
    WinTest02.c:389: error: `hChild' undeclared (first use in this function)
    MSVC++ 6:
    ...\WinTest02.c(382) : error C2143: syntax error : missing ')' before ';'
    ...\WinTest02.c(382) : error C2059: syntax error : ')'
    ...\WinTest02.c(386) : error C2181: illegal else without matching if
    line 382 has the if(LOWORD(wParam)... statement on it. but in their example, the exact same code works. so i tried copying over their entire WndProc() function, and it still gave me that error. so is there really a problem with that code? b/c i've been staring at it, bashing my head to no avail.. thanks.
    Registered Linux User #380033. Be counted: http://counter.li.org

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    Try moving the declaration of HWND hChild (= NULL) to the top of the function.

    You are using .c files, which don't allow variable declarations in the middle of functions.
    They must be using .cpp files which do allow this type of declaration.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    ::meekly objects::
    they download as .c files and on the website of the tutorial they state they will only be using .c files, no cpp. lol but they do use C++ style comments (at least what i was taught were C++ style comments... // instead of /* */)
    i'm still getting the same error though, no matter where HWND hChild is declared. what i dont get is it wants a ) before the ; on that line, but there is no ; on that line ?


    POPUP "&Edit"
    BEGIN
    So i just commented out the if part of my statement including the else so that it would just execute the code for the else situation..and it compiled and ran. *is really confused* ??
    End

    MENUITEM "&Redo", ID_EDIT_REDO
    /* yep..lamer 8-) booyah */
    so anyways, i tried different conditionals to see if something was going wrong in the if statement.. i changed my code to use whiles and i got the same error.
    Code:
    default:
    {
    409-> while (LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
        {
             DefFrameProc(hwnd, g_hMDIClient, WM_COMMAND, wParam, lParam);
        }
        while (!LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
        {
             HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE, 0, 0);
             if (hChild)
             {
                  SendMessage(hChild, WM_COMMAND, wParam, lParam);
             }
         }
    }
    [error]WinTest02.c:409: error: syntax error before ';' token
    WinTest02.c:413: error: syntax error before ';' token
    WinTest02.c:416: error: `hChild' undeclared (first use in this function)
    WinTest02.c:416: error: (Each undeclared identifier is reported only once
    WinTest02.c:416: error: for each function it appears in.)[/error]
    Last edited by willc0de4food; 05-17-2005 at 01:58 AM.
    Registered Linux User #380033. Be counted: http://counter.li.org

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    >>they download as .c files

    hmmmmmmmmmm....OK.....

    You are including windows.h or there would be other errors..
    Not the error if the resources were not included...


    Did you cut and paste the code?
    Prahaps there is a character in there we can't see...

    Could you post the file so I can have a look at the rest of the code..
    Your not missing a brace ( } ) further up are you?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    by posting the file do you mean to paste all of the code in [code] tags? (its > 600 lines i believe) or do you mean to upload it to a website and then post a link to it on here? because i believe that would be easier and would shorten the post in a good way, lol.

    but i'm at college right now so i'll check back when i get home & post.
    Registered Linux User #380033. Be counted: http://counter.li.org

  8. #8
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    The code you have posted is correct, and should not generate any errors on a C compiler. You error is probably somewhere else in the function. You can probably just post the function in question, instead of the all the code.

  9. #9
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    Registered Linux User #380033. Be counted: http://counter.li.org

  10. #10
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Have you #defined ID_MDI_FIRSTCHILD, becuase it's not something pre-defined by #including windows.h. Check out http://www.winprog.org/tutorial. They tell you the purpose for that definition and how you should define it. If you haven't then that's probably the source of all of your errors, since there should be a number there, but instead, there's a bunch of characters that the compiler has no idea what to do with. That's one thing I wish a compiler could do more well: tell you if you're trying to use a pre-definition that isn't defined. But, sadly, computers cannot read our minds and we have to figure out if this is the source of an error ourselves.

    If it's not that, I'd still bet that you're using something that hasn't been defined, based on the error you got and the fact that there's an error on each line where it was used. The rest were probably caused because stuff like that throws off the compiler's reading.
    Last edited by Jaken Veina; 05-17-2005 at 04:19 PM.

  11. #11
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    Don't have time right now to get it to compile without the res.h file. If you post it I will try again...

    I would...

    Comment out all the code. Leave only the case/break and see if it compiles. Then add the code back to find the culprit.

    Good luck.....

    EDIT: Opps
    Last edited by novacain; 05-17-2005 at 08:50 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  12. #12
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    http://www.freewebs.com/anarchy85/Res.h
    http://www.freewebs.com/anarchy85/Res.rc

    theres the other two files if you want to try to compile.
    whats opps? :-[
    commenting & checking now...



    // edit
    k, this is the entirety of my function now:
    Code:
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {        
         switch(msg)
         {
            case WM_COMMAND:
                 switch(LOWORD(wParam))
                 {
                       default:
                       {
                             if (LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
                             {
                                   DefFrameProc(hwnd, g_hMDIClient, WM_COMMAND, wParam, lParam);
                             }
                             else
                             {
                                   HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE, 0, 0);
                                   if (hChild)
                                   {
                                         SendMessage(hChild, WM_COMMAND, wParam, lParam);
                                   }
                             }
                       }
                       break;
                 }
            break;
         }
         return 0;
    }
    and i still get the error also, i know that you dont need to include the break; for the default: situation, i just like to have it there just in case i accidently add some code after the default: lol. so the problem is in another function..i just dont know where? *starts searching*... except there is NO code before this except for the #include's, #define's, and HWND declarations..


    >:O the most furiating part is that if you remove the conditional, it compiles! *this is frustrating..and i can't focus on my hw b/c of it * lol
    Last edited by willc0de4food; 05-18-2005 at 12:06 AM.
    Registered Linux User #380033. Be counted: http://counter.li.org

  13. #13
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER! I HATE THE COMPUTER!

    So I hard coded the number for ID_MDI_FIRSTCHILD (50000) in the if statement...compiles without a hitch >:O >:O >:O >:O >:O >:O >:O >:O
    but i'm still clueless as to how the ........ingsonofa..........pieceof........ has problems with one thing but not the other....
    Registered Linux User #380033. Be counted: http://counter.li.org

  14. #14
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    Welcome to the wonderful world of programming Windows!
    Please leave your sanity at the door.



    Put the defines in a seperate header (or edit the res.h and add there if you dare!)


    EDIT:
    Once you get past the frustration ect *, it feels good to have solved it yourself?

    (*and get a replacement for the bits of your PC you smashed)
    Last edited by novacain; 05-18-2005 at 01:08 AM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  15. #15
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    hahahaha ^_^ idk if my sanity even made it to the door.. but yea, it does feel good to have figured out the problem. which i will never understand, but i solved. and yea.. i wasn't sure if i wanted to stick those #define's in my header file b/c in their example, they were in the main code and in wondering if that could cause a problem, thats where they were placed. lol however, theres an updated version of my code and header / rc files that can be attained from the links above.


    Now, for a NEW headache ^_^ i want to incorporate a simple XOR encryption.. just so that when the file is opened in like notepad, my girlfriend or mom wouldn't be able to read it or be able to figure out "oh.. he just made a=b, b=c, etc.. this is the code i've come up with so far:
    Code:
    case ID_ENCRYPT_TEXT:
                        {
                             char algorithm[25] = "Az!By@Cx#Dw$Ev%Fu^Gt&Hs*";
                             int i;
                             DWORD dwTextLength;
                             dwTextLength = GetWindowTextLength(hwnd);
                             if(dwTextLength > 0)// No need to bother if there's no text.
                             {
                                    LPSTR pszText;
                                    pszText = (LPSTR)GlobalAlloc(GPTR, dwTextLength + 1);
                                    if(pszText != NULL)
                                    {
                                      char windowText[dwTextLength + 1];
                                      for (i = 0; i <= dwTextLength; i++)
                                      {
                                          windowText[i] = pszText[i];
                                      }
                                      if(windowText != NULL)
                                      {
                                             for (i = 0; i <= dwTextLength; i++)
                                             {
                                                 windowText[i] = windowText[i] ^ algorithm[i % 20];
                                             }
                                             SetWindowText(hwnd, windowText);
                                      }
                                    }
                             }                                    
                        }
                        break;
    but of course..when i click it, it does nothing. i probably have it placed wrong, and am trying to use something wrong.. but this wasn't part of the tutorial. this is something i want to do out of curiosity and self need, lol. so, any suggestions? thanks


    // on a side note, as for the icons included in the code, i uploaded those as well
    // shibbyinc.ico | txticon.ico
    Last edited by willc0de4food; 05-18-2005 at 02:51 AM.
    Registered Linux User #380033. Be counted: http://counter.li.org

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to make a windows application
    By crvenkapa in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2007, 09:59 AM
  2. Editor design: Traditional MDI versus Tabbed MDI
    By psychopath in forum Game Programming
    Replies: 7
    Last Post: 01-22-2007, 06:48 AM
  3. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 03:44 AM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21