Click to See Complete Forum and Search --> : How to actually "DO" something...
Forger
Feb 26th, 2001, 08:40 PM
I know how to make message boxes and how to quit the program...but how do I make the program do different things? :confused:
HarryW
Feb 26th, 2001, 08:44 PM
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:
Forger
Feb 26th, 2001, 08:54 PM
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?
HarryW
Feb 26th, 2001, 09:40 PM
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,
Forger
Feb 26th, 2001, 09:46 PM
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
parksie
Feb 27th, 2001, 05:45 AM
If you look at the Platform SDK on MSDN Under User Interface->Windowing there's lots of info on different control types.
Forger
Feb 27th, 2001, 03:30 PM
Sorry but I'm having a hell of a time finding it...can you show me a link when you have time? :)
parksie
Feb 27th, 2001, 03:34 PM
Okay...I'm at home now, so:
http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/winui/controls_1m5v.htm
To change the caption of a label, send the WM_SETTEXT message.
SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) "MyText");
Forger
Feb 27th, 2001, 04:23 PM
:eek: Does it really take that much code to make a static control!?!?!?!?? :eek: yikes!
Technocrat
Feb 27th, 2001, 04:26 PM
Welcom to the C++ world.
Your not in VB anymore. ;)
parksie
Feb 27th, 2001, 04:26 PM
Yep. It does. However, you can use Resources, which are a great time-saver.
Forger
Feb 27th, 2001, 04:28 PM
how would I make a resource file?
parksie
Feb 27th, 2001, 04:33 PM
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
Forger
Feb 27th, 2001, 04:44 PM
Is it possible to make my own class for the controls? Possibly add that to a header? Or should I start memorizing...
parksie
Feb 27th, 2001, 04:46 PM
You could if you really wanted to :) I am, but it's nowhere near finished.
Forger
Feb 27th, 2001, 04:59 PM
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)
SendMessage(hWnd_Of_Static, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) "MyText");
parksie
Feb 28th, 2001, 01:37 PM
Megatron, if you're going to use LPCTSTR then you must surround the constant in _T():
SendMessage(hWnd_of_static, WM_SETTEXT, 0, (LPCTSTR)_T("MyText"));
Forger
Feb 28th, 2001, 05:20 PM
Thanks guys, you've been a great help! :D
Thank you soooooo much!!! :D :D :D :D
Technocrat
Feb 28th, 2001, 05:23 PM
Originally posted by parksie
Megatron, if you're going to use LPCTSTR then you must surround the constant in _T():
SendMessage(hWnd_of_static, WM_SETTEXT, 0, (LPCTSTR)_T("MyText"));
Why the _T parksie? I have never had to use it before.
parksie
Feb 28th, 2001, 05:30 PM
It's all to do with Unicode. For example, you have the following code:
TCHAR *pStr = _T("Hello!");
Normally, it would resolve to:
char *pStr = "Hello!";
...but if you define Unicode:
#define UNICODE
wchar_t *pStr = L"Hello!";
The L"Hello!" bit tells the compiler to allocate 2 bytes per character.
HarryW
Feb 28th, 2001, 05:30 PM
I think it converts the string to Unicode, if it isn't already Unicode.
Forger
Feb 28th, 2001, 05:32 PM
Megatrons worked for me :confused:
Technocrat
Feb 28th, 2001, 05:33 PM
Learn something new every day :)
HarryW
Feb 28th, 2001, 05:34 PM
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?
parksie
Feb 28th, 2001, 05:35 PM
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 :(
parksie
Feb 28th, 2001, 05:37 PM
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?
Wak
Mar 6th, 2001, 05:26 AM
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
SteveCRM
Mar 6th, 2001, 08:30 AM
If you check my other thread (Menus(API)), Parksie explains how to use resource files.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.