I know how to make message boxes and how to quit the program...but how do I make the program do different things? :confused:
Printable View
I know how to make message boxes and how to quit the program...but how do I make the program do different things? :confused:
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 :rolleyes:
5 posts and already an award...I'm bursting with pride :D
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?
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,
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 :D
If you look at the Platform SDK on MSDN Under User Interface->Windowing there's lots of info on different control types.
Sorry but I'm having a hell of a time finding it...can you show me a link when you have time? :)
Okay...I'm at home now, so:
http://msdn.microsoft.com/library/de...trols_1m5v.htm
To change the caption of a label, send the WM_SETTEXT message.
Code:SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) "MyText");
:eek: Does it really take that much code to make a static control!?!?!?!?? :eek: yikes!
Welcom to the C++ world.
Your not in VB anymore. ;)
Yep. It does. However, you can use Resources, which are a great time-saver.
how would I make a resource file?
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
Is it possible to make my own class for the controls? Possibly add that to a header? Or should I start memorizing...
You could if you really wanted to :) I am, but it's nowhere near finished.
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)
Code:SendMessage(hWnd_Of_Static, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) "MyText");
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"));
Thanks guys, you've been a great help! :D
Thank you soooooo much!!! :D :D :D :D
Why the _T parksie? I have never had to use it before.Quote:
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"));
It's all to do with Unicode. For example, you have the following code:
Normally, it would resolve to:Code:TCHAR *pStr = _T("Hello!");
...but if you define Unicode:Code:char *pStr = "Hello!";
The L"Hello!" bit tells the compiler to allocate 2 bytes per character.Code:#define UNICODE
wchar_t *pStr = L"Hello!";
I think it converts the string to Unicode, if it isn't already Unicode.
Megatrons worked for me :confused:
Learn something new every day :)
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?
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 :(
You're right on the TCHAR thing. You can take advantage of this with the STL by replacing string with basic_string<TCHAR>.Quote:
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?
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?
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
If you check my other thread (Menus(API)), Parksie explains how to use resource files.