Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Well I've been working on a program, it's kinda big, I guess.
- It has multiple source files, but not all are big:
- main.cpp
- [code]
- /* Include the file PreProcessor Calls.h into this file */
- #include "PreProcessor Calls.h"
- /* Entry point of my application */
- int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpsCmdLine, int iCmdShow)
- {
- /* Call the SetUpWindowClass function
- "1": Title for the window class
- 255: Rgb for window background color
- 255: rGb for window background color
- 255: rgB for window background color
- hInstance: Module handle
- See the SetUpWindowClass function for more information on how these arguments are used
- It is in the Functions.h file
- */
- if (!SetUpWindowClass ("1", 255, 255, 255, hInstance))
- {
- /* Notify the user that the window class has failed, then exit the program */
- MessageBox (NULL, "Window class failed", NULL, NULL);
- return 0;
- }
- /* Create the parent window. WS_NO_RESIZE is defined in the file "Defines.h"*/
- hWnd = CreateWindowEx (WS_EX_CLIENTEDGE, "1", "-LeetGamer-'s PSPAIO", WS_NO_RESIZE, 0, 0, 0, 0, NULL, NULL, hInstance, NULL);
- /* Notify the user if the window creation has failed */
- if (!hWnd)
- {
- /* Notify the user that the window creation has failed, then exit the program */
- MessageBox (NULL, "Window creation failed", NULL, NULL);
- return 0;
- }
- /* Load and set the menu */
- HMENU hmMenu = LoadMenu (hInstance, MAKEINTRESOURCE (ID_MENU));
- SetMenu (hWnd, hmMenu);
- /* Show the window to the user */
- ShowWindow (hWnd, SW_SHOWMAXIMIZED);
- /* Call the SetUpAndCreateChildWindows function, this function will create all the child windows used in my MDI
- hWnd: Window handle to the parent window.
- */
- if (!SetUpAndCreateChildWindows (hWnd))
- {
- /* Notify the user that the chld window creation has failed, then exit the program */
- MessageBox (hWnd, "Child window creation failed", NULL, NULL);
- return 0;
- }
- /* Call the HideAllChildWindows function, this function is small:
- void HideAllChildWindows ()
- {
- for (int iLoopCounter = 0; iLoopCounter < 10; iLoopCounter++)
- {
- ShowWindow (hWndC [iLoopCounter], SW_HIDE);
- }
- return;
- }
- Its job is to ShowWindow (hWndC [], SW_HIDE); all the handles in the hWndC array.
- Why I do this will be shown a few lines down.
- */
- HideAllChildWindows ();
- /* Here I show the welcome child window. This has some text that will tell the user how to use the program.
- I used the last function call to hide all the other windows, and only show this one on start up.
- */
- ShowWindow (hWndC [0], SW_SHOW);
- /* Message loop */
- MSG uMsg;
- while (GetMessage (&uMsg, NULL, 0, 0) > 0)
- {
- TranslateMessage (&uMsg);
- DispatchMessage (&uMsg);
- }
- /* Exit program */
- return 0;
- }
- [/code]
- PreProcessor Calls.h
- [code]
- /* Include Windows.h into this file */
- #include <Windows.h>
- /* Include all my local header files */
- #include "Defines.h"
- #include "Globals.h"
- #include "Function Prototypes.h"
- #include "WindowProcedure.h"
- #include "Functions.h"
- [/code]
- Defines.h
- [code]
- /* This file is easy to understand if you know C/C++, so, I won't comment on it. */
- #define WS_NO_RESIZE WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX
- #define WS_CHILD_WINDOW WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_CHILD|WS_VISIBLE
- #define WS_MULTI_LINE_EDIT WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_MULTILINE
- #define ID_MENU 0x1337
- #define IDM_MENU_EXIT 0x1338
- #define IDM_MENU_FEATURES_PS2DIS_HEX_FIXER 0x1339
- #define IDM_MENU_FEATURES_IMPOSTER_GENERATOR 0x1340
- #define IDM_MENU_FEATURES_CODE_ARCHIVE_NITEPR 0x1341
- #define IDM_MENU_FEATURES_CODE_ARCHIVE_CWCHEAT 0x1342
- #define IDM_MENU_FEATURES_WELCOME 0x1343
- #define PS2DIS_HEX_FIXER_INPUT 0x1344
- [/code]
- Globals.h
- [code]
- /* Global variables */
- /* The main/parent window's handle */
- HWND hWnd = NULL;
- /* An array of window handles for the child windows */
- HWND hWndC [10];
- [/code]
- Function Prototypes.h
- [code]
- /* Function prototypes/declairations */
- bool SetUpWindowClass (char*, int, int, int, HINSTANCE);
- bool CreateChildWindows (HWND);
- bool SetUpAndCreateChildWindows (HWND);
- void HideAllChildWindows ();
- [/code]
- WindowProcedure.h
- [code]
- /* This namespace holds all the window procedures */
- namespace WindowProcedures
- {
- /* This namespace holds all the child window procedures */
- namespace CWP
- {
- // Welcome window
- LRESULT CALLBACK CWP_1 (HWND hWnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_CLOSE:
- ShowWindow (hWnd, SW_SHOWMINIMIZED);
- return 0;
- break;
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hDC = BeginPaint (hWnd, &ps);
- int iY = 0;
- char* cpaText [5];
- cpaText [0] = "Welcome to -LeetGamer-'s PSPAIO (PSP All in one) v1!";
- cpaText [1] = "This program will help people with a number of things, if they have a CFW";
- cpaText [2] = "To use the features click on the \"Features\" drop down.";
- cpaText [3] = "If you need any help with using this program then contact me with the \"Contact Me\" drop down.";
- cpaText [4] = "If you have any ideas for new features that I should add please contact me with the info";
- for (int iLoopCounter = 0; iLoopCounter < 5; iLoopCounter++, iY += 20)
- {
- TextOut (hDC, 0, iY, cpaText [iLoopCounter], strlen (cpaText [iLoopCounter]));
- }
- EndPaint (hWnd, &ps);
- }
- break;
- }
- return DefWindowProc (hWnd, uMsg, wParam, lParam);
- }
- // Ps2Dis.exe Hex Value Fixer
- LRESULT CALLBACK CWP_2 (HWND hWnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam)
- {
- HINSTANCE hInstance = GetModuleHandle (NULL);
- switch (uMsg)
- {
- case WM_CLOSE:
- ShowWindow (hWnd, SW_SHOWMINIMIZED);
- return 0;
- break;
- case WM_CREATE:
- CreateWindowEx (WS_EX_CLIENTEDGE, "edit", "", WS_MULTI_LINE_EDIT, 0, 0, 150, 300, hWnd, (HMENU) PS2DIS_HEX_FIXER_INPUT, hInstance, NULL);
- break;
- }
- return DefWindowProc (hWnd, uMsg, wParam, lParam);
- }
- // Imposter generator
- LRESULT CALLBACK CWP_3 (HWND hWnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_CLOSE:
- ShowWindow (hWnd, SW_SHOWMINIMIZED);
- return 0;
- break;
- }
- return DefWindowProc (hWnd, uMsg, wParam, lParam);
- }
- // Code Archive NitePR
- LRESULT CALLBACK CWP_4 (HWND hWnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_CLOSE:
- ShowWindow (hWnd, SW_SHOWMINIMIZED);
- return 0;
- break;
- }
- return DefWindowProc (hWnd, uMsg, wParam, lParam);
- }
- // Code Archive CwCheat
- LRESULT CALLBACK CWP_5 (HWND hWnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_CLOSE:
- ShowWindow (hWnd, SW_SHOWMINIMIZED);
- return 0;
- break;
- }
- return DefWindowProc (hWnd, uMsg, wParam, lParam);
- }
- };
- /* Main/Parent window procedure */
- LRESULT CALLBACK MainWindowProcedure (HWND hWnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_CLOSE:
- DestroyWindow (hWnd);
- break;
- case WM_DESTROY:
- PostQuitMessage (0);
- break;
- case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case IDM_MENU_EXIT:
- DestroyWindow (hWnd);
- break;
- /* These will hide all the windows then it will show the window that the user selected */
- case IDM_MENU_FEATURES_WELCOME:
- HideAllChildWindows ();
- ShowWindow (hWndC [0], SW_SHOW);
- break;
- case IDM_MENU_FEATURES_PS2DIS_HEX_FIXER:
- HideAllChildWindows ();
- ShowWindow (hWndC [1], SW_SHOW);
- break;
- case IDM_MENU_FEATURES_IMPOSTER_GENERATOR:
- HideAllChildWindows ();
- ShowWindow (hWndC [2], SW_SHOW);
- break;
- case IDM_MENU_FEATURES_CODE_ARCHIVE_NITEPR:
- HideAllChildWindows ();
- ShowWindow (hWndC [3], SW_SHOW);
- break;
- case IDM_MENU_FEATURES_CODE_ARCHIVE_CWCHEAT:
- HideAllChildWindows ();
- ShowWindow (hWndC [4], SW_SHOW);
- break;
- }
- break;
- }
- return DefWindowProc (hWnd, uMsg, wParam, lParam);
- }
- };
- [/code]
- Functions.h
- [code]
- /*
- Function: SetUpWindowClass ()
- Arguments:
- char* cpTitle: Holds the title of the window class
- int iR: Holds the Rgb of the window's bg color
- int iG: Holds the rGb of the window's bg color
- int iB: Holds the rgB of the window's bg color
- HINSTANCE hInstance: Holds the module handle
- Function's job:
- Set up a working window class
- Returns: true if all was good, false if something failed
- */
- bool SetUpWindowClass (char* cpTitle, int iR, int iG, int iB, HINSTANCE hInstance)
- {
- WNDCLASSEX WindowClass; /* Declair the window class structure */
- WindowClass.cbClsExtra = 0; /* Extra bytes to allocate for the class */
- WindowClass.cbWndExtra = 0; /* Extra bytes to allocate for the window */
- WindowClass.cbSize = sizeof (WNDCLASSEX); /* The size of the class */
- WindowClass.style = 0; /* The style */
- WindowClass.lpszClassName = cpTitle; /* The class name, I use the first argument here */
- WindowClass.lpszMenuName = NULL; /* The menu name */
- /* Here is where I fill in WindowClass.lpfnWndProc
- I use if statements to see what class title was passed into this function,
- I use a different window procedure (they are held in a namespace) for each class title
- because, well, I want it like that :P */
- if (cpTitle == "1") WindowClass.lpfnWndProc = WindowProcedures::MainWindowProcedure;
- else if (cpTitle == "2") WindowClass.lpfnWndProc = WindowProcedures::CWP::CWP_1;
- else if (cpTitle == "3") WindowClass.lpfnWndProc = WindowProcedures::CWP::CWP_2;
- else if (cpTitle == "4") WindowClass.lpfnWndProc = WindowProcedures::CWP::CWP_3;
- else if (cpTitle == "5") WindowClass.lpfnWndProc = WindowProcedures::CWP::CWP_4;
- else if (cpTitle == "6") WindowClass.lpfnWndProc = WindowProcedures::CWP::CWP_5;
- WindowClass.hInstance = hInstance; /* Module handle */
- WindowClass.hCursor = LoadCursor (NULL, IDC_ARROW); /* The cursor */
- WindowClass.hbrBackground = CreateSolidBrush (RGB (iR, iG, iB)); /* The background color */
- WindowClass.hIcon = LoadIcon (NULL, IDI_APPLICATION); /* Large icon */
- WindowClass.hIconSm = LoadIcon (NULL, IDI_APPLICATION); /* Small icon */
- if (!RegisterClassEx (&WindowClass)) return false; /* If the window class registration failed then return false */
- else return true; /* Else return true */
- }
- /*
- Function: SetUpAndCreateChildWindows ()
- Arguments:
- HWND hWnd: Holds the window handle to the main/parent window
- Function's Job:
- Set up the window classes for, and create the child windows
- Returns: true is all was good, false if something failed
- */
- bool SetUpAndCreateChildWindows (HWND hWnd)
- {
- HINSTANCE hInstance = GetModuleHandle (NULL); /* Put the module handle in hInstance */
- if (!SetUpWindowClass ("2", 255, 255, 255, hInstance)) return false; /* Set up the window class */
- hWndC [0] = CreateWindowEx (WS_EX_CLIENTEDGE, "2", "Welcome", WS_CHILD_WINDOW, 0, 0, 650, 140, hWnd, NULL, hInstance, NULL); /* Create the "Welcome" window */
- if (!hWndC [0]) return false; /* Check if the "Welcome" window was created right or not, if not return false */
- if (!SetUpWindowClass ("3", 255, 255, 255, hInstance)) return false; /* Set up another window class for the "Ps2Dis Hex Fixer" window */
- hWndC [1] = CreateWindowEx (WS_EX_CLIENTEDGE, "3", "Ps2Dis Hex Fixer", WS_CHILD_WINDOW, 0, 0, 700, 480, hWnd, NULL, hInstance, NULL); /* Create the "Ps2Dis Hex Fixer" window */
- if (!hWndC [1]) return false; /* Check if the "Ps2Dis Hex Fixer" window was created right or not, if not return false */
- if (!SetUpWindowClass ("4", 255, 255, 255, hInstance)) return false; /* Set up another window class for the "Imposter Generator" window */
- hWndC [2] = CreateWindowEx (WS_EX_CLIENTEDGE, "4", "Imposter Generator", WS_CHILD_WINDOW, 0, 0, 540, 140, hWnd, NULL, hInstance, NULL); /* Create the "Imposter Generator" window */
- if (!hWndC [2]) return false; /* Check if the "Imposter Generator" window was created right or not, if not return false*/
- if (!SetUpWindowClass ("5", 255, 255, 255, hInstance)) return false; /* Set up another window class for the "Code Archive (NitePR)" window */
- hWndC [3] = CreateWindowEx (WS_EX_CLIENTEDGE, "5", "Code Archive (NitePR)", WS_CHILD_WINDOW, 0, 0, 540, 140, hWnd, NULL, hInstance, NULL); /* Create the "Code Archive (NitePR)" window */
- if (!hWndC [3]) return false; /* Check if the "Code Archive (NitePR)" window was created right or not, if not return false */
- if (!SetUpWindowClass ("6", 255, 255, 255, hInstance)) return false; /* Set up another window class for the "Code Archive (CwCheat)" window */
- hWndC [4] = CreateWindowEx (WS_EX_CLIENTEDGE, "6", "Code Archive (CwCheat)", WS_CHILD_WINDOW, 0, 0, 540, 140, hWnd, NULL, hInstance, NULL); /* Create the "Code Archive (CwCheat)" window */
- if (!hWndC [4]) return false; /* Check if the "Code Archive (CwCheat)" window was created right or not, if not return false */
- return true; /* All has gone good, return true */
- }
- /*
- Function: HideAllChildWindows ()
- Arguments: None
- Function's Job:
- Use ShowWindow (hWndC [], SW_HIDE); on all child window handles.
- This will hide them all from the user, I will then show then when I want to.
- Returns: None
- This function is really simple to understand so I won't comment on it
- */
- void HideAllChildWindows ()
- {
- for (int iLoopCounter = 0; iLoopCounter < 10; iLoopCounter++)
- {
- ShowWindow (hWndC [iLoopCounter], SW_HIDE);
- }
- return;
- }
- [/code]
- Resource.rc
- [code]
- /* This file is easy to understand if you know the Win32 API, so, I won't comment on it. */
- #include "Defines.h"
- ID_MENU MENU
- BEGIN
- POPUP "&File"
- BEGIN
- MENUITEM "&Exit", IDM_MENU_EXIT
- END
- POPUP "&Features"
- BEGIN
- MENUITEM "&Welcome Message", IDM_MENU_FEATURES_WELCOME
- MENUITEM "&Ps2Dis Hex Fixer", IDM_MENU_FEATURES_PS2DIS_HEX_FIXER
- MENUITEM "&Imposter Generator", IDM_MENU_FEATURES_IMPOSTER_GENERATOR
- POPUP "&Code Archive"
- BEGIN
- MENUITEM "&NitePR Format Codes", IDM_MENU_FEATURES_CODE_ARCHIVE_NITEPR
- MENUITEM "&CwCheat Format Codes", IDM_MENU_FEATURES_CODE_ARCHIVE_CWCHEAT
- END
- END
- END
- [/code]
- Here is the project download: http://www.sendspace.com/file/hqx08p
- And the .exe download: http://www.sendspace.com/file/st8gel
- Now here is where my problem is :P
- If you run the program, and you go to "Ps2Dis Hex Value Fixer" from the "Features" drop down a new window will pop up. But I can't type in the edit control, can anyone help me with this? I know it might be hard for some of you guys to read that much code (Well, it looks like a lot) but it's not that much.
- Thanks !!!!!!!!
Advertisement
Add Comment
Please, Sign In to add comment