Click here to Skip to main content
15,879,474 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CListCtrl Pin
Hamid_RT24-Feb-06 3:09
Hamid_RT24-Feb-06 3:09 
AnswerRe: CListCtrl Pin
James R. Twine24-Feb-06 3:09
James R. Twine24-Feb-06 3:09 
QuestionIOCP - when a socket is closed ? Pin
yani dzhurov24-Feb-06 2:41
yani dzhurov24-Feb-06 2:41 
AnswerRe: IOCP - when a socket is closed ? Pin
James R. Twine24-Feb-06 3:02
James R. Twine24-Feb-06 3:02 
GeneralRe: IOCP - when a socket is closed ? Pin
yani dzhurov24-Feb-06 3:39
yani dzhurov24-Feb-06 3:39 
GeneralRe: IOCP - when a socket is closed ? Pin
James R. Twine24-Feb-06 4:47
James R. Twine24-Feb-06 4:47 
GeneralRe: IOCP - when a socket is closed ? Pin
George Nistor1-Aug-09 22:11
George Nistor1-Aug-09 22:11 
QuestionResizing windows Pin
Waldermort24-Feb-06 2:30
Waldermort24-Feb-06 2:30 
I'm having a few problems while trying to correctly display and position the controls on my dialog.

This is a simple Win32 project, of which there are very few examples and tutorials. Why is MFC forced upon us?

Anyway. I am trapping the WM_SIZE and calling the following function:
void ResizeWindow(HWND hwnd, RECT& rMain)
{
	RECT rNewMain;
	HWND hList,hListBorder,hComment,hCommentBorder;
	RECT rList,rListBorder,rComment,rCommentBorder;

	GetWindowRect(hwnd,&rNewMain);
	// store the origional size
	// prevent resizing less than this
	static int minW = rMain.right - rMain.left;
	static int minH = rMain.bottom - rMain.top;

	int width = rNewMain.right - rNewMain.left;
	int height = rNewMain.bottom - rNewMain.top;

	// set the smallest size
	bool resize = false;
	if (width < minW) {
		resize = true;
		width = minW;
	}
	if (height < minH) {
		resize = true;
		height = minH;
	}
	if (resize) {
		SetWindowPos(hwnd,NULL,0,0,width,height,SWP_NOZORDER | SWP_NOMOVE);
		return;
	}

	int changeW = width - (rMain.right-rMain.left);
	int changeH = height - (rMain.bottom-rMain.top);
	
	hList = GetDlgItem(hwnd,IDC_LIST);
	GetWindowRect(hList,&rList);
	hListBorder = GetDlgItem(hwnd,IDC_LIST_BORDER);
	GetWindowRect(hListBorder,&rListBorder);	
	hComment = GetDlgItem(hwnd,IDC_COMMENT);
	GetWindowRect(hComment,&rComment);	
	hCommentBorder = GetDlgItem(hwnd,IDC_COMMENT_BORDER);
	GetWindowRect(hCommentBorder,&rCommentBorder);

	SetWindowPos(hListBorder,NULL,
		0,
		0,
		(rListBorder.right - rListBorder.left) + changeW,
		(rListBorder.bottom - rListBorder.top) + changeH,
		SWP_NOZORDER | SWP_NOMOVE);
	SetWindowPos(hList,NULL,
		0,
		0,
		(rList.right - rList.left) + changeW,
		(rList.bottom - rList.top) + changeH,
		SWP_NOZORDER | SWP_NOMOVE);
	SetWindowPos(hCommentBorder,NULL,
		rCommentBorder.left,
		rCommentBorder.top + changeH,
		(rCommentBorder.right - rCommentBorder.left) + changeW,
		(rCommentBorder.bottom - rCommentBorder.top),
		SWP_NOZORDER);
	SetWindowPos(hComment,NULL,
		rComment.left,
		rComment.top,
		(rComment.right - rComment.left) + changeW,
		(rComment.bottom - rComment.top),
		SWP_NOZORDER);

	rMain.bottom += changeH;
	rMain.right += changeW;
}

The resizing works without a hitch, but for the 'Comment' controls, I want them to remain at the bottom of the window and only for their width to change. Problem is, those controls simply disappear when resizing the window. I have also tried using the MoveWindow() function with exactly the same results. Any ideas?

Also, when clicking the 'Maximize' button, the window maximizes but the controls remain unaffected. I thought WM_SIZE was supposed to catch it with SIZE_MAXIMIZED in the wParam?

And another little problem is the flickering. I have noticed that WM_SIZE is sent repeatedly while the window is being resized, but according to MSDN it's supposed to be sent after the window size has changed. Whats the deal?
AnswerRe: Resizing windows Pin
David Crow24-Feb-06 2:54
David Crow24-Feb-06 2:54 
GeneralRe: Resizing windows Pin
Waldermort24-Feb-06 3:47
Waldermort24-Feb-06 3:47 
GeneralRe: Resizing windows Pin
Blake Miller24-Feb-06 6:20
Blake Miller24-Feb-06 6:20 
AnswerRe: Resizing windows Pin
Waldermort24-Feb-06 5:01
Waldermort24-Feb-06 5:01 
GeneralRe: Resizing windows Pin
Blake Miller24-Feb-06 6:23
Blake Miller24-Feb-06 6:23 
GeneralRe: Resizing windows Pin
David Crow24-Feb-06 6:24
David Crow24-Feb-06 6:24 
Questionabout UNICODE Pin
HOW WHAT24-Feb-06 2:02
HOW WHAT24-Feb-06 2:02 
AnswerRe: about UNICODE Pin
toxcct24-Feb-06 2:15
toxcct24-Feb-06 2:15 
AnswerRe: about UNICODE Pin
PJ Arends24-Feb-06 2:35
professionalPJ Arends24-Feb-06 2:35 
QuestionMedical Image Processing Pin
spyrus24-Feb-06 2:01
spyrus24-Feb-06 2:01 
AnswerRe: Medical Image Processing Pin
Divyang Mithaiwala24-Feb-06 2:33
Divyang Mithaiwala24-Feb-06 2:33 
AnswerRe: Medical Image Processing Pin
Saurabh.Garg24-Feb-06 2:53
Saurabh.Garg24-Feb-06 2:53 
GeneralRe: Medical Image Processing Pin
spyrus24-Feb-06 2:57
spyrus24-Feb-06 2:57 
AnswerRe: Medical Image Processing Pin
Chris Losinger24-Feb-06 3:21
professionalChris Losinger24-Feb-06 3:21 
Questionneed to access a data base without creating a dsn Pin
RavishB24-Feb-06 1:40
RavishB24-Feb-06 1:40 
AnswerRe: need to access a data base without creating a dsn Pin
David Crow24-Feb-06 2:56
David Crow24-Feb-06 2:56 
QuestionDynamically Increasing Arrays Pin
Spykraft24-Feb-06 1:30
Spykraft24-Feb-06 1:30 

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.