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 


[WinApi C++]How to make Fixed Window Size?[NVM]Other Q.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Feb 09, 2009 2:19 pm    Post subject: [WinApi C++]How to make Fixed Window Size?[NVM]Other Q. Reply with quote

as title says Rolling Eyes

+
i tried to make after you start app , it appears on center of screen.
found something about SM_CXSCREEN, but it doesnt appear at center of screen Shocked


Last edited by Wiw3K on Mon Feb 09, 2009 5:38 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: Mon Feb 09, 2009 2:25 pm    Post subject: Reply with quote

GetSystemMetrics (namely SM_CXSCREEN / SM_CYSCREEN) and a little math.
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Feb 09, 2009 4:10 pm    Post subject: Reply with quote

dam , cant find it how to center my window after popup... Confused

i have this, ok so if i delete /2 (there can be any number), my app appear somewhere , i cant see it.

GetSystemMetrics(SM_CXSCREEN)/2,
GetSystemMetrics(SM_CYSCREEN)/2,

but i want to the Center of Screen Rolling Eyes
halp
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Mon Feb 09, 2009 4:16 pm    Post subject: Reply with quote

This code assumes that hWnd is the handle to the window you want to center.

Code:
RECT window;
GetWindowRect(hWnd, &window);
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
int wndHeight = window.bottom - window.top;
int wndWidth = window.right - window.left;
SetWindowPos(hWnd, 0, (screenWidth/2) - (wndWidth/2), (screenHeight/2) - (wndHeight/2), newWidth, newHeight, 0);


Last edited by talkerzero on Mon Feb 09, 2009 5:03 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Feb 09, 2009 4:39 pm    Post subject: Reply with quote

@up
wow so this way this works Razz

error C2065: 'newWidth' : undeclared identifier
error C2065: 'newHeight' : undeclared identifier


erm


---edit---
i declared them

int newHeight;
int newWidth;


and everything works exept my window doesnt appear on screen but OFFscreen xD
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Mon Feb 09, 2009 5:02 pm    Post subject: Reply with quote

Shit, I messed up my variables. In SetWindowPos change newWidth and newHeight to wndWidth and wndHeight.

With the old code, it's not moving them offscreen, it's setting their width and height to 0.

Here ya go. This should work fine.

Code:
RECT window;
GetWindowRect(hWnd, &window);
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
int wndHeight = window.bottom - window.top;
int wndWidth = window.right - window.left;
SetWindowPos(hWnd, 0, (screenWidth/2) - (wndWidth/2), (screenHeight/2) - (wndHeight/2), wndWidth, wndHeight, 0);
Back to top
View user's profile Send private message Visit poster's website
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Feb 09, 2009 5:08 pm    Post subject: Reply with quote

2 Things appear after i click Run.

1.
http://i40.tinypic.com/r0p1xu.png
2.
http://i41.tinypic.com/2dhe43m.png
and after i click 2x Continue - My Application appear :O

when i build it , cant open my exe an Critical Error appear :O
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Feb 09, 2009 5:27 pm    Post subject: Reply with quote

Rolling Eyes Are you fucking serious?

It tells you what the hell is wrong right in the error.
You called it when hWnd is not initialized, and hell from the images you gave, it looks like you havent even registered the windows class.
You might wanna call it after hWnd is given a return from CreateWindowEx.
You can even call it in WM_CREATE if you want.

Or you can just not even use SetWindowPos and create the window at those very coordinates.

_________________
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Feb 09, 2009 5:29 pm    Post subject: Reply with quote

NVM FIXED.
my fault , i forgot to change something heh Razz Thanks alot guys Smile


btw.
how to make if i hold mouse button , my custom cursor(already have) will change to other custom and after i let it go it change back ?


on button click , change Ico ? this way?
Back to top
View user's profile Send private message
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Mon Feb 09, 2009 5:40 pm    Post subject: Reply with quote

Who would've guessed the API would be SetCursor!
Back to top
View user's profile Send private message MSN Messenger
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Feb 09, 2009 6:12 pm    Post subject: Reply with quote

1. I Want Load Cursor from .bmp.

i did it this way

defined
Code:
   HCURSOR hCurs1;

   //Load Cursor
   hCurs1 = LoadCursorFromFileA("OnClick.png");


then in whole app

Code:
   if (WM_LBUTTONUP)
    {
      SetCursor(hCurs1);
   }


No Errors but nothing happen after i click left mouse Rolling Eyes
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Feb 09, 2009 6:49 pm    Post subject: Reply with quote

wouldn't OnClick wanna be WM_LBUTTONDOWN.... ?

check GetLastError? See if hCurs1 is valid? It supports PNG?

_________________
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