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++ - Setting my window's position on center screen?

 
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: Sat Dec 26, 2009 1:34 am    Post subject: C++ - Setting my window's position on center screen? Reply with quote

How would i do this when the form is open?
all i know is CW_USEDEFAULT style
is there something else or should i manually change it's position when it's loaded?
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Dec 26, 2009 3:59 am    Post subject: Reply with quote

you want to move it to the center?

GetSystemMetrics() to get the size of the screen, then you can just do

center = screen_size / 2 - window_size / 2

call MoveWindow() with the new coordinates
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: Sat Dec 26, 2009 5:08 am    Post subject: Reply with quote

Awesome thanks :]
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Dec 26, 2009 5:43 am    Post subject: Reply with quote

make sure you take the window border and caption into consideration as well. GetSystemMetrics() can get the size for these also

i think you can get the size of the entire window with GetWindowRect()
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: Sat Dec 26, 2009 5:51 am    Post subject: Reply with quote

i think i'd be okay from here thanks Very Happy
but one more problem if i may
the thing is that i have my entry point that creates the main window but b4 that window is being initialized
i create a child window for choosing settings and right after i hit ok that window close itself and the main window is being loaded
but when the main window is being loaded it doesn't have any focus, and all other windows / application are hiding him
so i used SetForegroundwindow to set it the first in z order
and when i wanna use SetDlgItemText to set the text of some textbox
it's not working :\
any idea ?
lol nvm i figured it out :>
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