how to write a "click me" box

This is a discussion on how to write a "click me" box within the Windows Programming forums, part of the Platform Specific Boards category; what is the key words and library to exercute a box that require the user to click as an input?? ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    3

    how to write a "click me" box

    what is the key words and library to exercute a box that require the user to click as an input??

    p.s i mean what should i #include in my programme
    Last edited by raynon; 04-01-2010 at 11:01 PM.

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,167
    What library?

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    MessageBox()
    Code:
    #include <windows.h>
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  4. #4
    Registered User UltraKing227's Avatar
    Join Date
    Jan 2010
    Location
    USA, New york
    Posts
    123
    as cpjust says, you need MessageBox.

    MessageBox(NULL, YourStringTextHere, YourStringTitleHere, MB_OK);
    /* Sample of a messagebox */
    here is a working example:

    #include <windows.h>

    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
    {
    MessageBox(NULL, "Hi!", "Message: ", MB_OK);
    }
    however, if you want a messagebox which popups and only closes when
    you click anywhere in it. you have to look for Dialogs in Windows programming.

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    3
    what should i do if i wan 2 clickable box??

  6. #6
    Registered User UltraKing227's Avatar
    Join Date
    Jan 2010
    Location
    USA, New york
    Posts
    123
    what do you mean by that? do you mean two buttons in a box or
    something else?

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    You need to be more specific. No one is going to tell you how to do A or B. Try something and come back,

  8. #8
    Registered User
    Join Date
    Apr 2010
    Posts
    3
    i mean something looks like when you are having more than 1 tab, when you try to close the explorer, it shows a dialog box having "close current tab" and "close all tabs"

  9. #9
    Registered User UltraKing227's Avatar
    Join Date
    Jan 2010
    Location
    USA, New york
    Posts
    123
    first, learn Dialog Windows Programming (EFNet #Winprog).
    second, here is the algorithm:

    if Tabs > 1 then
    Make a Button with the text "Close all Tabs"
    end if

    Make a Button with the text "Close Current Tab"
    the first button (Close all Tabs) is created only if you have more than one
    tab. the second one (Close Current Tab) is created, with or without the first
    button. if hope this algorithm helps.

  10. #10
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    UltraKing227, whenever someone gives advice on how to do 'some' windows type stuff, I perk up. But your example does not work for me. I get a:
    "error C2664: 'MessageBoxW': cannot convert parameter 2 from 'const char [4]' to 'LPCWSTR'.

    I never have luck with any examples given in books either. There is something magical they never tell you about - some special way to set up the 'project' or some check-box in the 'properties'. I give up trying anymore and stick with "console" error messages and real 'C' code that doesn't have illegally named main procedures. Sorry, I get all dinosaury when I see this stuff and it never compiles right for me.
    Last edited by nonoob; 04-06-2010 at 03:38 PM.

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by nonoob View Post
    UltraKing227, whenever someone gives advice on how to do 'some' windows type stuff, I perk up. But your example does not work for me. I get a:
    "error C2664: 'MessageBoxW': cannot convert parameter 2 from 'const char [4]' to 'LPCWSTR'.

    I never have luck with any examples given in books either. There is something magical they never tell you about - some special way to set up the 'project' or some check-box in the 'properties'. I give up trying anymore and stick with "console" error messages and real 'C' code that doesn't have illegally named main procedures. Sorry, I get all dinosaury when I see this stuff and it never compiles right for me.
    Quick fix: change "strings" to L"strings" (with the L in front). ("LPCWSTR" is the gobbledygook for pointer to wide characters, interpreted as a string, or something like that, so you'll have to be using wchar_t and Long strings.)

    (I suppose the longer fix would be to find the Unicode setting and change it.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 01:59 PM
  2. No data showing in combo box
    By PJYelton in forum Windows Programming
    Replies: 6
    Last Post: 04-29-2005, 07:20 PM
  3. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  4. Bounding box problems with ID3DXSprite
    By VirtualAce in forum Game Programming
    Replies: 5
    Last Post: 12-16-2004, 08:15 AM
  5. Write to another programs edit box
    By Zahl in forum Windows Programming
    Replies: 2
    Last Post: 11-16-2002, 05:55 AM

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