Results 1 to 30 of 30

Thread: How to actually "DO" something...

  1. #1

    Thread Starter
    Junior Member Forger's Avatar
    Join Date
    Feb 2001
    Posts
    19
    I know how to make message boxes and how to quit the program...but how do I make the program do different things?
    Forger
    As in creator, not copier.

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    I think that wins the award for "most general question ever", congratulations.

    You make the program do different things by using different code in different ways, so that users can take different actions.

    Ask a silly question, get a silly answer
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Junior Member Forger's Avatar
    Join Date
    Feb 2001
    Posts
    19
    5 posts and already an award...I'm bursting with pride
    hehehe...should've known better when posting that

    Yeah sorry harry...that came out a little odd. Lets start with this:


    How would I put some text into a label?
    Forger
    As in creator, not copier.

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Are you new to C/C++? If so you would be better off sticking to console apps for a while. If you're not new to it though, well it depends on whether you want to use MFC or just plain API.

    I know how to create controls for Windows apps, but to be honest I don't take much more interet in it beyond that, I do almost all my stuff in DirectX. I'm sure someone else here will know the details though,
    Harry.

    "From one thing, know ten thousand things."

  5. #5

    Thread Starter
    Junior Member Forger's Avatar
    Join Date
    Feb 2001
    Posts
    19
    I think I am very comfortable with console programming...I took a look at parksie's windows example (API), and started to figure it out. I was able to figure out enough that I could change placement, sizes, caption, and even add buttons...now I'm trying to see how to make other controls and how to use them...

    So I am very new to windows programming (about 2 hours ) Thanks for your help Harry
    Forger
    As in creator, not copier.

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    If you look at the Platform SDK on MSDN Under User Interface->Windowing there's lots of info on different control types.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    Junior Member Forger's Avatar
    Join Date
    Feb 2001
    Posts
    19
    Sorry but I'm having a hell of a time finding it...can you show me a link when you have time?
    Forger
    As in creator, not copier.

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9
    Guest
    To change the caption of a label, send the WM_SETTEXT message.
    Code:
    SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) "MyText");

  10. #10

    Thread Starter
    Junior Member Forger's Avatar
    Join Date
    Feb 2001
    Posts
    19
    Does it really take that much code to make a static control!?!?!?!?? yikes!
    Forger
    As in creator, not copier.

  11. #11
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Welcom to the C++ world.
    Your not in VB anymore.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yep. It does. However, you can use Resources, which are a great time-saver.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  13. #13

    Thread Starter
    Junior Member Forger's Avatar
    Join Date
    Feb 2001
    Posts
    19
    how would I make a resource file?
    Forger
    As in creator, not copier.

  14. #14
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Add new file, and choose Resource Script. However, you really need to get to grips with Windows' event handling model before you do. Also, the Platform SDK is a prerequisite for doing any serious Windows C++ stuff.

    There's an example here: http://www.parksie.net/RawDlg.zip
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  15. #15

    Thread Starter
    Junior Member Forger's Avatar
    Join Date
    Feb 2001
    Posts
    19
    Is it possible to make my own class for the controls? Possibly add that to a header? Or should I start memorizing...
    Forger
    As in creator, not copier.

  16. #16
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You could if you really wanted to I am, but it's nowhere near finished.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  17. #17

    Thread Starter
    Junior Member Forger's Avatar
    Join Date
    Feb 2001
    Posts
    19
    the example on msdn shows how to animate a picture in the static control....can you show me how to just add text? (sorry about so many questions)
    Forger
    As in creator, not copier.

  18. #18
    Guest
    Code:
    SendMessage(hWnd_Of_Static, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) "MyText");

  19. #19
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Megatron, if you're going to use LPCTSTR then you must surround the constant in _T():
    Code:
    SendMessage(hWnd_of_static, WM_SETTEXT, 0, (LPCTSTR)_T("MyText"));
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  20. #20

    Thread Starter
    Junior Member Forger's Avatar
    Join Date
    Feb 2001
    Posts
    19
    Thanks guys, you've been a great help!

    Thank you soooooo much!!!
    Forger
    As in creator, not copier.

  21. #21
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Originally posted by parksie
    Megatron, if you're going to use LPCTSTR then you must surround the constant in _T():
    Code:
    SendMessage(hWnd_of_static, WM_SETTEXT, 0, (LPCTSTR)_T("MyText"));
    Why the _T parksie? I have never had to use it before.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  22. #22
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's all to do with Unicode. For example, you have the following code:
    Code:
    TCHAR *pStr = _T("Hello!");
    Normally, it would resolve to:
    Code:
    char *pStr = "Hello!";
    ...but if you define Unicode:
    Code:
    #define UNICODE
    
    wchar_t *pStr = L"Hello!";
    The L"Hello!" bit tells the compiler to allocate 2 bytes per character.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  23. #23
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    I think it converts the string to Unicode, if it isn't already Unicode.
    Harry.

    "From one thing, know ten thousand things."

  24. #24

    Thread Starter
    Junior Member Forger's Avatar
    Join Date
    Feb 2001
    Posts
    19
    Megatrons worked for me
    Forger
    As in creator, not copier.

  25. #25
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Learn something new every day
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  26. #26
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Seems I was right

    So, Parksie, TCHAR is either char or wchar_t depending on whether you've #defined your code as being Unicode?

    Also, I've never seen syntax like L"Hello!" before... anything else like that in C/C++? Anything not used with strings?
    Harry.

    "From one thing, know ten thousand things."

  27. #27
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    That's because the definitions change:

    Generic: LPCTSTR == const TCHAR*
    Normal: LPCTSTR == const char*
    Unicode: LPCTSTR == const wchar_t*

    So normally, you can mix-n-match and it will all work...however as soon as you define UNICODE, it all messes up
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  28. #28
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Originally posted by HarryW
    So, Parksie, TCHAR is either char or wchar_t depending on whether you've #defined your code as being Unicode?

    Also, I've never seen syntax like L"Hello!" before... anything else like that in C/C++? Anything not used with strings?
    You're right on the TCHAR thing. You can take advantage of this with the STL by replacing string with basic_string<TCHAR>.

    I don't recognise where the syntax comes from, either. It's slightly strange but I think it may be VC++ only...anyone with a different compiler got any info?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  29. #29
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Unhappy Adding Resources

    Hey all,
    OK, I've read all the posts on this page, several times, and I got 1 main question. How do I add a resource to a Win32 program. I'm guessing that you just add it, design it, and then use the #include statement, but I could be wrong. Umm, what's the general standard, and if so, do I receive messages from it, the same as I would already do?? Also, does this mean that I have to include any DLL's?? If so which one's. Greatly appreciated all the help. Thanx
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  30. #30
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    If you check my other thread (Menus(API)), Parksie explains how to use resource files.

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