I think loop is the worst plan, it waste a lot of CPU cycle. timer is OK and sometime thread is a good solution
digitalspace xjtu
Posts
-
Wait for event versus while / do loop or timer – academic questions -
Why a HANDLE created by CreateFile can be assigned to an objectOh, it is operator overload , thank you very much
-
Why a HANDLE created by CreateFile can be assigned to an objectthinks , got it
-
Why a HANDLE created by CreateFile can be assigned to an objectSome code segment in chapter 10 of "Windows via C/C++"(5th Edition) is
// Open the source file without buffering & get its size
CEnsureCloseFile hFileSrc = CreateFile(pszFileSrc,
GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_NO_BUFFERING |
FILE_FLAG_OVERLAPPED, NULL);Here "CEnsureCloseFile" is a class. The Author define Template class "CEnsureCleanup" which was used to clean some objects, then use a this Template define class CEnsureCloseFile My question is why the HANDLE created by "CreateFile" can be assigned to object hFileSrc . It seems rare. Do you offen do sth like this?
-
Run MFC Program Without Dialog ShowingIt seems no different compared with your original version. why it works?
-
Resizing Controls and TextsOnSize() method which respond to the change of windows could do this job
// Resize the list control contained in the view to
// fill the entire view when the view's window is
// resized. CMyView is a CView derived class.
void CMyView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// Resize list to fill the whole view.
m_List.MoveWindow (0, 0, cx, cy);
}1. keep the original size of dialog, suppose Old_width is original width of dialog. We also deal with the height like this 2. use GetWindowRect( LPRECT lpRect ), which Copies the dimensions of the bounding rectangle of the CWnd object to the structure pointed to by lpRect. From it you get New_Width (it is new width of dialog now) 3. calculate rate = Old_width/ New_Width . 4. use
CWnd* GetDlgItem(
int nID
) const;to get pointer(suppose ptr) of button or other control, use ptr->GetWindowRect( BtnRect ) to get boundary rect of button ( or other ..) calculate new rect of button( suppose new_btn_rect ) through rate and BtnRect (the height also shoud be consided) 5. use ptr->MoveWindows(new_btn_rect ) to move button and change its size
-
Run MFC Program Without Dialog ShowingFollowing Richard's idea , if you program based on MFC Dialog , I think you can change InitialInstance() like this ...........
BOOL myParameter; CMFCApplication4Dlg \*pMainWnd = new CMFCApplication4Dlg; if(myParameter) // need a dialog { pMainWnd->DoModal(); }else { // needn't a dialog pMainWnd->CreateEx(NULL,\_T("STATIC"), L"Hi", **WS\_BORDER** , //WS\_VISIBLE is not need CRect(-15, -15, -15, -15), NULL,NULL); // start a thread which include **while** loop, // that can keep dialog running until you stop it by yourself // otherwise the programe will exit very quickly }
........