| View previous topic :: View next topic |
| Author |
Message |
NuclearPowered Master Cheater
Reputation: 0
Joined: 30 Dec 2007 Posts: 345
|
Posted: Thu Jan 31, 2008 10:36 am Post subject: New to C++ |
|
|
I'm new to C++, I borrowed this C++ book from a friend but I know now that just going through the whole book isnt gonna teach me alot coz Ill forget alot anyway, it's better to just make program's and you'll learn from that, but the book doesnt explain how to make a graphics interfaced program, instead of just calculations through the console...
I just need a window and add some buttons to it which WriteProcessMemory.
Any tuts on that?
Thanks in advance.
|
|
| Back to top |
|
 |
Losplagos Expert Cheater
Reputation: 0
Joined: 21 Mar 2006 Posts: 172 Location: Knee deep in a c++ book
|
Posted: Thu Jan 31, 2008 10:42 am Post subject: |
|
|
Learn the basics first. For a basic window your using quite alot.
| Code: |
#include <windows.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
//Step 1: Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Step 2: Creating the Window
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"The title of my window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// Step 3: The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
|
I got this code from this site's tutorial http://www.winprog.org/tutorial/simple_window.html
And remember learn the standard c++ then move to the windows api.
_________________
Earthbound = 31337 |
|
| Back to top |
|
 |
Hans Henrik Expert Cheater
Reputation: 0
Joined: 18 Feb 2007 Posts: 178
|
|
| Back to top |
|
 |
NuclearPowered Master Cheater
Reputation: 0
Joined: 30 Dec 2007 Posts: 345
|
Posted: Thu Jan 31, 2008 10:44 am Post subject: |
|
|
Nope.
I was formally known as Nuclear898 on this forum till I got banned.
Thanks for helping
|
|
| Back to top |
|
 |
Losplagos Expert Cheater
Reputation: 0
Joined: 21 Mar 2006 Posts: 172 Location: Knee deep in a c++ book
|
Posted: Thu Jan 31, 2008 10:45 am Post subject: |
|
|
If your really going to learn c++ then Sams teach yourself c++ in 21 days is a good book.
_________________
Earthbound = 31337 |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu Jan 31, 2008 10:46 am Post subject: |
|
|
if your gonna do C++ you learn functional programming.
if you want easy drag and drop gui's then you learn C#.NET
For C++ there is .NET but i dont recomend using that since C# is just right there.
theForger's Win32 API Tutorial:
http://www.winprog.org/tutorial/
Edit: haha, i missed like eveyrones post cuz i got distractd and never hit submit until like 5 minutes later loll
_________________
|
|
| Back to top |
|
 |
Losplagos Expert Cheater
Reputation: 0
Joined: 21 Mar 2006 Posts: 172 Location: Knee deep in a c++ book
|
Posted: Thu Jan 31, 2008 11:20 am Post subject: |
|
|
Vc++ 08 hates theForgers winapi tutorial!!
| Quote: |
error C2440: '=' : cannot convert from 'const char [14]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [28]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [24]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast |
_________________
Earthbound = 31337 |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu Jan 31, 2008 11:35 am Post subject: |
|
|
nope, you just dont know how to define text as UNICODE
see unless you change your project settings to "Use Multi-byte charecter set" you MUST add 1 of the 3 below because you are using UNICODE
1. an L before the string
Example: L"Hi My Name is Lurc"
2. defining it using TEXT
Example: TEXT("Hi My Name is Lurc")
3. Including tchar.h and then using _T (same as TEXT but shorter and neater)
Example: _T("Hi My Name is Lurc")
_________________
Last edited by lurc on Thu Jan 31, 2008 12:36 pm; edited 1 time in total |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Thu Jan 31, 2008 12:30 pm Post subject: |
|
|
| lurc wrote: | | if you want easy drag and drop gui's then you learn C#.NET |
dialogs.
those tutorials go over them at some point.
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu Jan 31, 2008 1:09 pm Post subject: |
|
|
yes dialogs are there for C++ but im talking EASY.
even using dialogs needs a bit of knowledge about what your doing, with C# its drag and drop, double click for event, etc. its simple and you can learn quickly since eveyrthings basically already given to u.
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
|