| View previous topic :: View next topic |
| Author |
Message |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Sun Jun 29, 2008 3:55 pm Post subject: First question with C++ |
|
|
Edit: Fixed
_________________
Last edited by AndrewMan on Tue Jul 01, 2008 11:00 am; edited 1 time in total |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Jun 29, 2008 4:10 pm Post subject: |
|
|
What are you trying to do?
_________________
|
|
| Back to top |
|
 |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Sun Jun 29, 2008 4:22 pm Post subject: |
|
|
| samuri25404 wrote: | | What are you trying to do? |
Just a simple Form, with a button, click the button and it shows "hello world!"
_________________
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Jun 29, 2008 4:27 pm Post subject: |
|
|
You'll probably want to start off with a console application.
It's not nearly as easy as VB.NET, and no where similar to it either.
Look up some tutorials on it.
_________________
|
|
| Back to top |
|
 |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Sun Jun 29, 2008 4:29 pm Post subject: |
|
|
| samuri25404 wrote: | You'll probably want to start off with a console application.
It's not nearly as easy as VB.NET, and no where similar to it either.
Look up some tutorials on it. |
I got it to work with a console app. I can't find any tuts for like what it would be called a "message box" in .Net
_________________
|
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
|
| Back to top |
|
 |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Sun Jun 29, 2008 4:43 pm Post subject: |
|
|
Oh man this C++ is intense, so much different than .Net
If I make a form, than put a button on it, I don't get where I put this code? Keeps giving me "Link" Errors.
| Code: | int DisplayResourceNAMessageBox()
{
int msgboxID = MessageBox(
NULL,
(LPCWSTR)L"Resource not available\nDo you want to try again?",
(LPCWSTR)L"Account Details",
MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2
);
switch (msgboxID)
{
case IDCANCEL:
// TODO: add code
break;
case IDTRYAGAIN:
// TODO: add code
break;
case IDCONTINUE:
// TODO: add code
break;
}
return msgboxID;
} |
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Jun 29, 2008 5:09 pm Post subject: |
|
|
Get the basics down with console stuff first before you jump into windows. THEN read http://www.winprog.org/tutorial/index.html and understand it.
Anyway...
| Quote: | If the function succeeds, the return value is one of the following menu-item values.
... |
int msgboxID is simply going to hold the return value of MessageBox, depending on what it returns, we do something.
| Code: | int msgboxID;
msgboxID = MessageBox(hWnd, "Text", "Title", MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2);
switch (msgboxID)
{
case IDCANCEL:
MessageBox(hWnd, "CANCEL", "1", MB_OK);
break;
case IDTRYAGAIN:
MessageBox(hWnd, "TRYAGAIN", "2", MB_OK);
break;
case IDCONTINUE:
MessageBox(hWnd, "CONTINUE", "3", MB_OK);
break;
} |
|
|
| Back to top |
|
 |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Sun Jun 29, 2008 8:31 pm Post subject: |
|
|
Still not getting any of this, ill just stay with console for a while..
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Jun 29, 2008 8:50 pm Post subject: |
|
|
| AndrewMan wrote: | Still not getting any of this, ill just stay with console for a while..  |
What don't you get? I'll try to explain it better.
But, sticking with the console for now might be a good idea... or you can just do it from the console heh.
| Code: | #include <windows.h>
int mb;
int main(){
mb = MessageBox(NULL, "Text", "Title", MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2);
switch (mb)
{
case IDCANCEL:
MessageBox(NULL, "CANCEL", "1", MB_OK);
break;
case IDTRYAGAIN:
MessageBox(NULL, "TRYAGAIN", "2", MB_OK);
break;
case IDCONTINUE:
MessageBox(NULL, "CONTINUE", "3", MB_OK);
break;
}
} |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sun Jun 29, 2008 8:55 pm Post subject: |
|
|
I recommend reading this:
http://www.cplusplus.com/doc/tutorial/
If your going to go into Win32 API then you'll wanna read this as well:
http://www.winprog.org/tutorial/
And by Win32 API I mean what slovach's code snippet.
MessageBox is an API.
It's .NET Equivilent would be
MessageBox::Show(...)
_________________
|
|
| Back to top |
|
 |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Sun Jun 29, 2008 11:30 pm Post subject: |
|
|
Where do I put this? can you explain the steps for me just on how to make a form than add a button, than put this code into the button?
I think I can get started once I learn that.
and @Lurc, thanks for the links! I will check them out in a bit.
| Code: | #include <windows.h>
int mb;
int main(){
mb = MessageBox(NULL, "Text", "Title", MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2);
switch (mb)
{
case IDCANCEL:
MessageBox(NULL, "CANCEL", "1", MB_OK);
break;
case IDTRYAGAIN:
MessageBox(NULL, "TRYAGAIN", "2", MB_OK);
break;
case IDCONTINUE:
MessageBox(NULL, "CONTINUE", "3", MB_OK);
break;
}
} |
_________________
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun Jun 29, 2008 11:44 pm Post subject: |
|
|
We can't help you if you know shit about the API or C++. Read the tutorials and start off with making a basic window. It will go into more difficult concepts. You are just trying to go with a snippet and force learn >.>
And what the hell sort of snippet is that anyways?
I suggest the winprog tut by forgey.
_________________
|
|
| Back to top |
|
 |
AndrewMan Grandmaster Cheater Supreme
Reputation: 0
Joined: 01 Aug 2007 Posts: 1257
|
Posted: Sun Jun 29, 2008 11:50 pm Post subject: |
|
|
| blankrider wrote: | We can't help you if you know shit about the API or C++. Read the tutorials and start off with making a basic window. It will go into more difficult concepts. You are just trying to go with a snippet and force learn >.>
And what the hell sort of snippet is that anyways?
I suggest the winprog tut by forgey. |
I don't get the point of making a window when you can make a form that already has a window?
And no one answered my question yet. What do I make? a Win32 App? or a CLR? Or is it just an empty project, and in the sourcle files I add .cpp?
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Jun 29, 2008 11:58 pm Post subject: |
|
|
| AndrewMan wrote: | Where do I put this? can you explain the steps for me just on how to make a form than add a button, than put this code into the button?
I think I can get started once I learn that.
and @Lurc, thanks for the links! I will check them out in a bit.
| Code: | #include <windows.h>
int mb;
int main(){
mb = MessageBox(NULL, "Text", "Title", MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2);
switch (mb)
{
case IDCANCEL:
MessageBox(NULL, "CANCEL", "1", MB_OK);
break;
case IDTRYAGAIN:
MessageBox(NULL, "TRYAGAIN", "2", MB_OK);
break;
case IDCONTINUE:
MessageBox(NULL, "CONTINUE", "3", MB_OK);
break;
}
} |
|
That's not just a snippet, it's an entire console program. (That I brilliantly forgot to return 0 in)
| AndrewMan wrote: | | blankrider wrote: | We can't help you if you know shit about the API or C++. Read the tutorials and start off with making a basic window. It will go into more difficult concepts. You are just trying to go with a snippet and force learn >.>
And what the hell sort of snippet is that anyways?
I suggest the winprog tut by forgey. |
I don't get the point of making a window when you can make a form that already has a window?
And no one answered my question yet. What do I make? a Win32 App? or a CLR? |
CLR is managed code, you'd be right back to where you started.
You're getting ahead of yourself. Get the basics down, when you feel comfortable, go read the forgers stuff, and read it well. Win32 is simple enough to jump into if you have some footing... which you don't yet.
Some ideas, start off with your typical hello world in the console. Then maybe move onto a calculator. A calculator is a good project where you can put things like loops and handling input to use.
|
|
| Back to top |
|
 |
|