Q: Why can't Kill timer?
Originally posted: http://community.9cbs.net/expert/topicview.asp? Id = 3820107
A:
The first handle parameter hwnd of KillTimer and SetTimer should be consistent, this handle should be a window handle of the same thread. Second, the second parameter nidevent of SETTIMER and KILLTIMER should also be consistent. In general, Nidevent in Settimer needs to be set to not 0, unless the value of the first parameter hWnd is NULL. 1 setTimer The first parameter is not null, then Nidevent in Settimer needs to be set to non-0 value A. If successful, return a non-zero value, but this is not the ID of this Timer. To confirm that the same timer in TimerProc is required, you need to compare whether the parameters NIDEVENT and A of TimerProc are equal. In this case, Timer's operation should be:
Timerid0 = 5500; // for example settimer (g_wnd, timerid0, 2000, & timerproc); /// ...
Void __stddcall TimerProc (HWND HWND, UINT UMSG, UINT IDEVENT, DWORD DWTIME) {ifvent == Timerid0) {KillTimer (g_wnd, timerid0); /// ...}}
2
Settimer's HWND is set to NULL, and Nidevent will be ignored. If successful, return a non-zero value a, this A is the NidEvent of TimerProc. This should be operated at this time:
Timerid0 = setTimer (NULL, 0, 2000, & TIMERPROC);
/// ...
Void __stdcall TimerProc (HWND HWND, UINT UMSG, UINT Idevent, DWORD DWTIME)
{
IF (IDEvent == Timerid0)
{
Killtimer (NULL, TIMERID0);
/// ...
}
}
Q: Play a paragraph AVI, to loop full screen play
Originally posted address: http://community.9cbs.net/expert/topicview.asp? Id = 3137948
A:
MCI_DGV_PLAY_PARMS mciPlay; MCI_DGV_OPEN_PARMS mciOpen; mciOpen.dwCallback = 0L; mciOpen.wDeviceID = 0; mciOpen.lpstrDeviceType = "avivideo"; mciOpen.lpstrElementName = m_lpszFileName; mciOpen.lpstrAlias = NULL; mciOpen.dwStyle = WS_CHILD; mciOpen.hWndParent = hWnd; mciSendCommand (0, MCI_OPEN, MCI_OPEN_TYPE | // specify this command play file by specified device type MCI_OPEN_ELEMENT | // specify this command play MCI_DGV_PLAY_REPEAT | // repeatedly play MCI_DGV_ OPEN_PARENT, // couple to WS_CHILD parameter (DWORD) (LPMCI_DGV_OPEN_PARMS) & mciOpen);. MCI_DGV_STATUS_PARMS mciStatus; mciStatus.dwItem = MCI_DGV_STATUS_HWND; mciSendCommand (mciOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD) (LPMCI_STATUS_PARMS) & mciStatus); mciPlay.dwCallback = (Dword) hwnd; mciplay.dwfrom = 0; mcIPlay.dwto = 0; :: showwindow (* phwnd, sw_maximize); m_wmcideviceid = mciopen.wdeviceID;
McISendCommand (M_WMCIDEVICEID, MCI_PLAY, MCI_NOTIFY | MCI_DGV_PLAY_REPEAT | MCI_FROM, (DWORD) (LPMCI_DGV_PLAY_PARMS) & mcIPlay); Q: How to change the width of the frame window
Originally posted address: http://community.9cbs.net/expert/topicview.asp? Id = 3737745
A:
WM_NCCALCSIZE manually add the message response function: void CMainFrame :: OnNcCalcSize (BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR * lpncsp) {CMDIFrameWnd :: OnNcCalcSize (bCalcValidRects, lpncsp); if (bCalcValidRects) lpncsp-> rgrc [0] .bottom - = 32; // The next frame} is not enough, but also add this location with the color:
Void cmainframe :: onncpaint () {default (); //...draw your stuff}
Q: How to organize in the hard disk?
Originally posted address: http://community.9cbs.net/expert/topic/3832/3832691.xml? Temp = .6097223
A:
http://www.ntfs.com/
Q: How to set the desktop as a web page
Originally posted: http://community.9cbs.net/expert/topic/3751/3751227.xml? Temp = .484234
A:
IactiveDesktop * Pad; Componentsopt Opt;
HRESULT HR = :: COCREATEINSTANCE (CLSID_ACTIVEDESKTOP, NULL, CLSCTX_INPROC_SERVER, IID_IACTIVEDESKTOP, (VOID **) & PAD);
Opt.dwsize = sizeof (opt); opt.FactiveDesktop = OPT.FACTIVEDESKTOP = OPT.FENABLECMMPONENTS = true; hr = pad-> setdesktopItemOptions (& Opt, 0);
HR = PAD-> ApplyChanges (AD_APPLY_REFRESH);
Q: Start the program itself when the registry is started by modifying the registry.
Originally posted: http://community.9cbs.net/expert/topic/3772/3772931.xml? Temp = .3636896
A:
// find out the file name from given pathCString FindFileName (LPSTR path) {CString filename (path); int nIndex = filename.ReverseFind ( '//'); filename = filename.Mid (nIndex 1); return filename;}
// Query if the application will automatically start up when starting windowsBOOL IsAppAutoRunEnabled () {HKEY hKey; if (RegCreateKey (HKEY_CURRENT_USER, TEXT ( "Software // Microsoft //" "Windows // CurrentVersion // Run"), & hKey) = = ERROR_SUCCESS) {BOOL bEnabled; LPTSTR lpCurrentPath = NULL; lpCurrentPath = new CHAR [MAX_PATH]; GetModuleFileName (NULL, lpCurrentPath, MAX_PATH); CString filename = FindFileName (lpCurrentPath);
Benabled = (Error_Success == RegQueryValueex (HKEY, FileName.getBuffer (0), 0, NULL, NULL, NULL);
RegcloseKey (HKEY); delete [] lpCurrentpath; return benabled;}
Return false;}
// modify the registry to let the application run at window start up.bool enableappautorun () {hkey hkey;
if (RegCreateKey (HKEY_CURRENT_USER, TEXT ( "Software // Microsoft //" "Windows // CurrentVersion // Run"), & hKey) == ERROR_SUCCESS) {LPTSTR lpCurrentPath = NULL; lpCurrentPath = new CHAR [MAX_PATH]; GetModuleFileName (NULL , lpcurrentpath, max_path;
CString filename = FindFileName (LPCurrentPath); RegSetValueex (HKEY, FileName.getBuffer (0), 0, Reg_SZ, (Byte *) LpCurrentPath, Strlen (LPCurrentPath);
RegcloseKey (HKEY); RETURN TRUE;}
Return false;}