Can someone please help me?

I need a link for how to make an integer into a character...example...

int gwtstat =0;
if(gwtstat == "Password"){}

It is getting it to work with the quotes that is the problem...please help me....and thank you for reading this
That's weird! You mean to make an integer equivalent with a particular character string?
What are you trying to do? :)
Last edited on
Here...Ill post the code and you can see..I would like you to look at the WM_COMMAND area and tell me how I can set it to a specific variable for the password...I dont care if it is just numbers...I just need it to be a password so it closes the window after the correct password was entered...if not...a message indicating the wrong password...this program runs and was debugged...please help me....

#include <windows.h>
#include <iostream>
/* Declare Windows procedure */
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
char TextSaved[30];
HWND TextBox;

int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Password", /* Title Text */
WS_MINIMIZE, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
500, /* The programs width */
100, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
/* Translate virtual-key messages into character messages */
/* Send message to WindowProcedure */
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
switch (message) /* handle the messages */

TextBox = CreateWindow("EDIT", "", WS_BORDER | WS_CHILD | WS_VISIBLE,
10, 10, 400, 20,
hwnd, NULL, NULL, NULL);

CreateWindow("BUTTON", "SUBMIT",
420, 10, 70, 20,
hwnd, (HMENU) 1, NULL, NULL);

case 1:

int gwtstat =0;
gwtstat = GetWindowText(TextBox, &TextSaved[0], 30);
//char *t = &TextSaved[0];
if (gwtstat == "Password") {
PostQuitMessage (0);
MessageBox(hwnd, TextSaved, TextSaved, MB_OK);
gwtstat = GetWindowText(TextBox, &TextSaved[0], 30);
if (gwtstat == 0)
//Prompt for input.....
MessageBox(hwnd, "Please enter a password...", "No Input...", MB_OK);

PostQuitMessage (0); /* send a WM_QUIT to the message queue */
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
return 0;
Your input password is saved in the buffer - TextSaved (dont use TextSaved[0]) , not the gwtstat (in this case it holds the length of the copied string).
in the next if statement, use strcmp() to compare TextSaved with your password.
gwtstat = GetWindowText(TextBox, &TextSaved, 30);
if (strcmp(TextSaved, "Password") == 0) {
PostQuitMessage (0); 

Note that you should put your source in the code format macro, it's make your code more readable.

Bad EL, correct me please :)
Last edited on
umm...EL? and I compiled it and this is what i got in Dev-C++...

90 52 C:\*\*\*
Cannot convert 'char (*)[30]' to 'CHAR*' for argument '2' to 'int GetWindowTextA(HWND__*, CHAR*, int)'

It says that in the compiler and I dont know what it means...I think it has to do with either the "int" or the CHAR.....I really need help on this one...:)
Sorry, you should remove the ampersand before TextSaved and your code will work fine:
GetWindowText(TextBox, TextSaved, 30);
And by EL i mean English :)

EDIT: remember to include string.h
Last edited on
OMG...thanks helped so much.....I can finally make it a successful program...thanks to all..

Topic archived. No new replies allowed.