Click here to Skip to main content
15,897,519 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Question about several popular sleep methods. Pin
Blake Coverett4-Oct-03 21:53
Blake Coverett4-Oct-03 21:53 
GeneralRe: Question about several popular sleep methods. Pin
George24-Oct-03 22:00
George24-Oct-03 22:00 
GeneralRe: Question about several popular sleep methods. Pin
Johnny ²6-Oct-03 1:14
Johnny ²6-Oct-03 1:14 
GeneralRe: Question about several popular sleep methods. Pin
George26-Oct-03 16:39
George26-Oct-03 16:39 
Generalerror Pin
R. Thomas4-Oct-03 18:56
R. Thomas4-Oct-03 18:56 
GeneralRe: error Pin
Dominik Reichl4-Oct-03 23:02
Dominik Reichl4-Oct-03 23:02 
GeneralRe: error Pin
R. Thomas5-Oct-03 0:03
R. Thomas5-Oct-03 0:03 
QuestionCalculating window size based on bitmap and titlebar/border? Pin
Kayembi4-Oct-03 15:53
Kayembi4-Oct-03 15:53 
Hi,

I have a program that generates a window depending on user settings. The window contains a bitmap that the user selects, and can have various border types (dialog, client edge, no border), and may or may not have a title bar.

The window is supposed to be the size of the bitmap that is selected. However, I have just realised that my window size does not take account of the titlebar or border of the window.

For instance, I calculate my window position and size like this currently:

<br />
BITMAP BMPSize;<br />
HBITMAP SizeCheckBMP;<br />
....<br />
GetObject(SizeCheckBMP,sizeof(BMPSize), &BMPSize);<br />
....<br />
//center window in screen:<br />
xpos = (GetSystemMetrics(SM_CXSCREEN)/2)-(BMPSize.bmWidth/2);<br />
ypos = (GetSystemMetrics(SM_CYSCREEN)/2)-(BMPSize.bmHeight/2);<br />
//calculate dimensions:<br />
width = BMPSize.bmWidth;<br />
height = BMPSize.bmHeight;<br />
....<br />
myWnd = CreateWindowEx(<br />
	WS_EX_TOOLWINDOW,<br />
	"my_win_class",<br />
	WS_DLGFRAME,<br />
	NULL,<br />
	xpos,<br />
	ypos,<br />
	width,<br />
	height,<br />
	NULL,<br />
	NULL,<br />
	hInst<br />
	NULL);<br />


The problem here is, suppose the bitmap is 640x480 pixels in size - the window created by this code will be exactly that size too, which doesn't work if there is a title bar and border, as these will be included in these dimensions. So the bottom of the bitmap will be cut off by the exact number of pixels that the titlebar takes up, or the right and bottom of the bitmap will be cut off by the number of pixels that the dialog frame border takes up. I hope that makes sense.

Could someone please suggest a better way of calculating my window size so that it sizes itself to exactly fit whole of the bitmap, plus the title bar and border?

Many thanks for any help,
KB
AnswerRe: Calculating window size based on bitmap and titlebar/border? Pin
Michael Dunn4-Oct-03 16:53
sitebuilderMichael Dunn4-Oct-03 16:53 
GeneralRe: Calculating window size based on bitmap and titlebar/border? Pin
PJ Arends4-Oct-03 16:57
professionalPJ Arends4-Oct-03 16:57 
GeneralRe: Calculating window size based on bitmap and titlebar/border? Pin
Michael Dunn4-Oct-03 17:08
sitebuilderMichael Dunn4-Oct-03 17:08 
GeneralRe: Calculating window size based on bitmap and titlebar/border? Pin
Kayembi5-Oct-03 3:43
Kayembi5-Oct-03 3:43 
AnswerRe: Calculating window size based on bitmap and titlebar/border? Pin
PJ Arends4-Oct-03 16:55
professionalPJ Arends4-Oct-03 16:55 
GeneralRe: Calculating window size based on bitmap and titlebar/border? Pin
J. Dunlap4-Oct-03 16:57
J. Dunlap4-Oct-03 16:57 
GeneralRegistry code refuses to work for no reason, help! Pin
Steven M Hunt4-Oct-03 14:22
Steven M Hunt4-Oct-03 14:22 
GeneralRe: Registry code refuses to work for no reason, help! Pin
Michael Dunn4-Oct-03 16:56
sitebuilderMichael Dunn4-Oct-03 16:56 
QuestionKazaa searchresult ctrl?? Pin
Stefan Dahlin4-Oct-03 14:04
Stefan Dahlin4-Oct-03 14:04 
GeneralNetwork interface Pin
Florin Ochiana4-Oct-03 12:17
Florin Ochiana4-Oct-03 12:17 
GeneralRe: Network interface Pin
Max Santos5-Oct-03 5:12
Max Santos5-Oct-03 5:12 
GeneralPRINTING -VC++ Pin
radha vijay4-Oct-03 9:11
radha vijay4-Oct-03 9:11 
GeneralRe: PRINTING -VC++ Pin
LunaticFringe4-Oct-03 22:26
LunaticFringe4-Oct-03 22:26 
GeneralRe: PRINTING -VC++ Pin
radha vijay6-Oct-03 14:18
radha vijay6-Oct-03 14:18 
GeneralKey accelerators Pin
BoudewijnEctor4-Oct-03 5:53
BoudewijnEctor4-Oct-03 5:53 
GeneralRe: Key accelerators Pin
Mike Dimmick4-Oct-03 7:48
Mike Dimmick4-Oct-03 7:48 
GeneralTimers in MFC Pin
BoudewijnEctor4-Oct-03 5:41
BoudewijnEctor4-Oct-03 5:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.