| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon May 26, 2008 8:33 am Post subject: |
|
|
for visual styles add this to the top of your project
| Code: | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' "\
"version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#include <commctrl.h>
#pragma comment( lib, "COMCTL32.lib" ) |
then in your WinMain add
| Code: | INITCOMMONCONTROLSEX Init;
Init.dwICC = ICC_STANDARD_CLASSES;
Init.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCommonControlsEx(&Init); |
To set the password char use the message EM_SETPASSWORDCHAR (http://msdn.microsoft.com/en-us/library/bb761653(VS.85).aspx)
use one of these functions:
GetDlgItemText
GetWindowText
or use this message
WM_GETTEXT
Edit for your edit:
You cannot compare a string like that in C++, you can only compare single charecters. so for strings Use the function strcmp (for ASCII) or _tcscmp (for UNICODE, included in tchar.h)
If the function returns 0 the string's are the same. _________________
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Mon May 26, 2008 8:38 am Post subject: |
|
|
nice thx bro.
allthough i used the WM_GETTEXT message and i did got the text but when i compare it with other text i get nothing
it's like he's avoiding the "if" part
edit:
just saw your edit XD so i can use strcmp(str1,str2)? _________________
Stylo |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon May 26, 2008 8:40 am Post subject: |
|
|
not quite a bool, it returns 0 if there the same, i think it returns non-zero or -1 if there not the same.
example:
| Code: | TCHAR tszStr1[50];
_tcscpy( tszStr1, _T("String 1") );
if ( _tcscmp( tszStr1, _T("String 1") ) == 0 )
{
MessageBox( NULL, _T("Strings are the same"), _T("_tcscmp"), MB_OK );
} |
_________________
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Mon May 26, 2008 8:42 am Post subject: |
|
|
my code goes like this:
| Code: |
char Password[255];
if (strcmp(Password,"aaa") == 0)
MessageBox(NULL,"same","same",MB_OK);
|
but still it's avoiding the "if" part _________________
Stylo |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon May 26, 2008 8:44 am Post subject: |
|
|
try to add an "else MessageBox( NULL, "Not same", 0, 0 );"
and see if that pops up.
and does char Password contain any text? cuz if your declaring it right above then comparing it without assigning it a string or charecter then the function isn't going to return the same. _________________
Last edited by lurc on Mon May 26, 2008 8:45 am; edited 1 time in total |
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon May 26, 2008 8:47 am Post subject: |
|
|
read my edit. _________________
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Mon May 26, 2008 8:55 am Post subject: |
|
|
well it's really wierd this is my code for the comparing part if you wanna look at it:
| Code: |
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_CLOSE_BUTTON:
PostQuitMessage(0);
break;
case IDC_LOGIN_BUTTON:
char Password[255];
SendMessage(hPassword,WM_GETTEXT,MAX_PATH,(LPARAM)Password);
if (strcmp(Password,"123") == 0)
{
MessageBox(NULL,L"YES",L"YES",MB_OK | MB_ICONEXCLAMATION);
}
else
{
MessageBox(NULL,L"NO",L"NO",MB_OK | MB_ICONEXCLAMATION);
}
break;
}
break;
|
it's always go to the else part _________________
Stylo |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon May 26, 2008 9:05 am Post subject: |
|
|
instead of WM_GETTEXT do this:
| Code: |
if ( GetWindowText( hPassword, Password, MAX_PATH ) == NULL )
{
MessageBox( NULL, "Fill in the box", 0, 0 );
}
else
{
// do your check
} |
it uses the WM_GETTEXT Message but its a bit easier to use. _________________
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Mon May 26, 2008 5:00 pm Post subject: |
|
|
| Code: | if ( !strcmp(Password,"123" ) ) {
// Same
} |
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Mon May 26, 2008 10:00 pm Post subject: |
|
|
it's not helping me that much
now it's pops up the YES message even if i insert wrong password :\ _________________
Stylo |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Mon May 26, 2008 10:04 pm Post subject: |
|
|
Let me see your code. _________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Tue May 27, 2008 6:24 am Post subject: |
|
|
it's few posts above
anyway:
| Code: |
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_CLOSE_BUTTON:
PostQuitMessage(0);
break;
case IDC_LOGIN_BUTTON:
char Password[255];
SendMessage(hPassword,WM_GETTEXT,MAX_PATH,(LPARAM)Password);
if (strcmp(Password,"123") == 0)
{
MessageBox(NULL,L"YES",L"YES",MB_OK | MB_ICONEXCLAMATION);
}
else
{
MessageBox(NULL,L"NO",L"NO",MB_OK | MB_ICONEXCLAMATION);
}
break;
}
break;
|
_________________
Stylo |
|
| Back to top |
|
 |
|