Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] A few little noobie questions XD
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 26, 2008 8:11 am    Post subject: [C++] A few little noobie questions XD Reply with quote

how do i enable visual styles in C++ ?
i'v done creating all my window and now i want my controls have visual styles Confused
oh and one more question .. how do i make that i'll see only password characters in my textbox?

and when i wanna check the text inside a textbox how can i get the text?
edit: nvm i got the text but i want to compare it with something and when i do that it does nothing even if the text is the same
Code:

char Password[255];
SendMessage(hPassword,WM_GETTEXT,MAX_PATH,(LPARAM)Password);
if (Password == "asd")
{
 //
 // etc ..
 //
}

_________________
Stylo
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon May 26, 2008 8:33 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 26, 2008 8:38 am    Post subject: Reply with quote

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
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon May 26, 2008 8:40 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 26, 2008 8:42 am    Post subject: Reply with quote

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
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon May 26, 2008 8:44 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 26, 2008 8:45 am    Post subject: Reply with quote

yea it pops up with not same Confused
edit to your edit:
yea i get the text that inside the textbox in it using WM_GETTEXT

_________________
Stylo


Last edited by Stylo on Mon May 26, 2008 8:47 am; edited 1 time in total
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon May 26, 2008 8:47 am    Post subject: Reply with quote

read my edit.
_________________
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 26, 2008 8:55 am    Post subject: Reply with quote

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
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon May 26, 2008 9:05 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 26, 2008 11:22 am    Post subject: Reply with quote

but the thing is that i get the text inside the char[] variable
that's the good part it's only the comparing thing that have trouble Confused

_________________
Stylo
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Mon May 26, 2008 5:00 pm    Post subject: Reply with quote

Code:
if ( !strcmp(Password,"123" ) ) {
   // Same
}
Back to top
View user's profile Send private message MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 26, 2008 10:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Mon May 26, 2008 10:04 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue May 27, 2008 6:24 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites