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++] how to constantly change the text in static control

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Thu May 01, 2008 9:51 pm    Post subject: [c++] how to constantly change the text in static control Reply with quote

i want to add HP,MP and exp hook i had to my trainer and display these info on my trainer using one of its static control.

but i can't seem to edit static control text once its created in my dialog.

i tried this but didn't work

Code:

SetWindowText(GetDlgItem(hWnd,IDC_STATIC_1),"blah blah blah");


also if its possible, how would i change certain static control to a different color.

it seems to me static control is very limited :S


thank you in advance
Bizarro

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils


Last edited by Bizarro on Thu May 01, 2008 10:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu May 01, 2008 10:05 pm    Post subject: Reply with quote

SetDlgItemText
Back to top
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Thu May 01, 2008 10:07 pm    Post subject: Reply with quote

slovach wrote:
SetDlgItemText


doesn't seem to work with static control =S

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu May 01, 2008 10:21 pm    Post subject: Reply with quote

Bizarro wrote:
slovach wrote:
SetDlgItemText


doesn't seem to work with static control =S


Give it its own reference number (hMenu parameter with CreateWindowEx();) and use that instead of the static declaration (-1).
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Thu May 01, 2008 10:53 pm    Post subject: Reply with quote

well i did something like this, lemme find it
Code:

HWND Static1;

Static1 = CreateWindow(TEXT("STATIC"), TEXT("Text"), WS_CHILD | WS_VISIBLE, 0, 0, 100, 15, hWnd, 0, hInstance, NULL);

SetWindowText( Static1, TEXT("Texty text"));


that works for me

_________________
Back to top
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Fri May 02, 2008 12:13 am    Post subject: Reply with quote

ty guys

@snooate

setwindowtext still doesn't work for constant updating:S


edit:
looks like setwindowtext and SetDlgItemText only work for me in WM_INITDIALOG. if i used it any where outside it (ie WM_COMMAND), it will become not effective. any one know whats the problem?

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Fri May 02, 2008 4:57 am    Post subject: Reply with quote

i've used my way when using hotkeys (WM_HOTKEY), it should really work for all commands
_________________
Back to top
View user's profile Send private message
Renkokuken
GO Moderator
Reputation: 4

Joined: 22 Oct 2006
Posts: 3249

PostPosted: Fri May 02, 2008 5:17 am    Post subject: Reply with quote

Are you redrawing the window after each update to the static?
Back to top
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Fri May 02, 2008 9:47 am    Post subject: Reply with quote

Renkokuken wrote:
Are you redrawing the window after each update to the static?

any idea how do i redraw the dialog static control?
i tried updatewindow(); didn't work

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri May 02, 2008 10:02 am    Post subject: Reply with quote

Bizarro wrote:
slovach wrote:
SetDlgItemText


doesn't seem to work with static control =S

The first parameter (HWND) should be the parent window.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Fri May 02, 2008 10:07 am    Post subject: Reply with quote

Redraw the window using RedrawWindow:

Code:
RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE );


Also try calling InvalidateRect before that if you need to as well. (Just fill in the hWnd for that as well then null the rest of the params to invalidate the full window.)

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Fri May 02, 2008 10:16 am    Post subject: Reply with quote

Wiccaan wrote:
Redraw the window using RedrawWindow:

Code:
RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE );


Also try calling InvalidateRect before that if you need to as well. (Just fill in the hWnd for that as well then null the rest of the params to invalidate the full window.)


wiccan somehow it still doesn't update Confused

i made 2 buttons (ON and OFF) on my dialog

after i use createwindow for the static control in WM_INITDIALOG

i did the setwindowtext in WM_ON and WM_OFF under WM_COMMAND


Code:
      
   case WM_INITDIALOG:
      {

 Static1 = CreateWindow(TEXT("STATIC"), TEXT("Text"), WS_CHILD | WS_VISIBLE, 0, 0, 100, 15, hWnd, 0, hInstance, NULL);
      ShowWindow( hWnd, SW_SHOW );

      }
      return TRUE;
case WM_COMMAND:
switch( wParam )
      {      
   case IDC_ON:

                      SetWindowText( Static1, TEXT("hp on"));
         InvalidateRect(hWnd,0,0);
                     RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE );
return true;
...




still didn't work Sad

setWindowText and SetDlgItemText only works within WM_INITDIALOG

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Fri May 02, 2008 11:19 am    Post subject: Reply with quote

Here is an example on using SetWindowText().
Code:

case WM_COMMAND:
      {
         if (HIWORD(wParam) == BN_CLICKED)
         {
            switch (LOWORD(wParam))
            {
            case btnOnOff:
               {
                  if (num)
                  {
                     SetWindowText(hStatic, "OFF");
                     SetWindowText(hButton, "OFF");
                     num--;
                  }
                  else
                  {
                     SetWindowText(hStatic, "ON");
                     SetWindowText(hButton, "ON");
                     num++;
                  }
               }
               break;
            }
         }
         break;
      }

I would only recommend using SetWindowText when you dynamically create the control. Since you are using are dialog, you should use SetDlgItemText.

Code:

case WM_COMMAND:
      {
         if (HIWORD(wParam) == BN_CLICKED)
         {
            switch (LOWORD(wParam))
            {
            case IDC_BTN_UP:
               {
                  char temp[MAX_PATH] = { 0 };
                  GetDlgItemText(hWnd, IDC_EDIT_UP, temp, MAX_PATH);
                  SetDlgItemText(hWnd, IDC_STATIC_UP, temp);
               }
               break;
            }
         }
      }
      return true;


I've provided the source for using SetWindowText and SetDlgItemText.
Back to top
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Fri May 02, 2008 10:32 pm    Post subject: Reply with quote

killer

if you looked my partial code up there, i did almost the same as ur example code.
but something must be wrong with my code. SetWindowText and SetDlgItemText doesn't work for me outside WM_WM_INITDIALOG

:S

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
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
Page 1 of 1

 
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