|
i just find these functions in MSDN.
the funcion DWORD GetIdleTime (void); and HRESULT GetIdleWait(WORD *pwIdleMinutes, WORD *pwDeadlineMinutes); both need include "Mstask.h".
but i found this header files is in the WinCE SDK.
my application is under Win XP/2000.
|
|
|
|
|
jakeyjia wrote: GetIdleTime
try GetLastInputInfo() function.
nave
|
|
|
|
|
thank you~ i got it~
note: in VC 6.0 must define the version like:
#define _WIN32_WINNT 0x0500
|
|
|
|
|
jakeyjia wrote: thank you~ i got it~
jakeyjia wrote: note: in VC 6.0 must define the version like:
#define _WIN32_WINNT 0x0500
_WIN32_WINNT denotes the verison of windows you use. And if you are using XP it is 0x501
nave
|
|
|
|
|
I'm trying to set a parameter through WMI.
I can read a value as follows:
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM CIM_VideoController"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
hr = pclsObj->Get(L"CurrentHorizontalResolution", 0, &vtProp, 0, 0);
But when I try to do a set as follows:
V_VT(&v) = VT_I4;
V_I4(&v) = 1024;
hr = pclsObj->Put(L"CurrentHorizontalResolution", 0, &v, VT_I4);
I get an error return value of: 0x80041005
Any guidance woudd be appreciated!
Jeremy
|
|
|
|
|
CIM_VideoController::CurrentHorizontalResolution
<br />
Data type: uint32<br />
Access type: Read-only<br />
Current number of horizontal pixels.<br />
so you can't set it by put method.
you can see more info in MSDN: http://msdn2.microsoft.com/en-us/library/aa388668.aspx[^]
|
|
|
|
|
Thanks -- I should have noticed the access-type. So, it seems that this stunning complicated wmi interface is just to get stuff.
So, back to ChangeDisplaySettings. I'll post another question on that!!
Jeremy
|
|
|
|
|
If I use SetWindowsHookEx() with the idHook argument as WH_CALLWNDPROC, if I want this to be a global hook and monitor messages to ALL windows in the current desktop, do I have to place the hook procedure defined in lpfn in a DLL? Also, if I want it to be a global hook, do I just set hMod to NULL and dwThreadId to 0?
Thanks for your help!
--PerspX
|
|
|
|
|
Perspx wrote: do I have to place the hook procedure defined in lpfn in a DLL
yes you need to put it in a dll.
Perspx wrote: do I just set hMod to NULL and dwThreadId to 0?
no hMod must specifiy the HINSTANCE of the dll. dwThreadId should be 0.
nave
|
|
|
|
|
Thank you very much
--PerspX
|
|
|
|
|
I don't really know exactly what this is called, so that may be why i haven't found any good information about it.. From one of my programs (a VC6.0 dialog based MFC application) i want to be able to check checkboxes, slide sliders etc of other MFC dialog based applications. Im not sure if its possible, but i would guess that it is since other programs can like hide windows and stuff. Is there a nifty way to do so in c++? (except for cheapy ways like moving the mouse and clicking by code)
Like CheckBox(SomeWindow, SomeName, 1); :P (i know it can't be that easy, but in general..)
Anybody have any experince with this, know what it might be called or have any urls?
Since i dont have anything to work with right now i am open to any information
thanks
//Johannes
|
|
|
|
|
Such a thing is possible if you first obtain the window handle of the checkbox, slider, etc., and then use SendMessage() to send window messages to it.
The hardest thing about this is determining the exact window to which you want to send the messages.
Keep in mind that in Vista, your manipulator app has to have high enough "integrity" to send messages to other processes.
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
You could use the EnumWindows() API to search for all of the windows that are open, then when you have found the right window, you could use the FindWindowEx() API to find the right child window owned by the window returned by EnumWindows(). Then, as said above, you could use the SendMessage API to send the designated message to the window.
Hope this helps!
--PerpspX
|
|
|
|
|
in addition to what Perspx said, you can use GetDlgItem() or EnumChildWindows() to get each controls in a dialog and then use GetClassName() to find which control it is.
nave
|
|
|
|
|
Thanks for the help
So im looking at the SendMessage, FindWindow and FindWindowEx, but im having trouble connecting them all,
I declare a HWND to "hold the window".
FindWindow("Control", 0); //Makes it so my program has control to the window called "Control" ?
Then i have to use FindWindowEx to set which dialog radio buttons /checkboxes should be set and to what
then SendMessage() to set it?
Might you know how i would connect these? Or is the some nice tutorial somewhere :/
thanks
//Johannes
|
|
|
|
|
Hi all,
I am trying to convert MFC code to Borland 6 C++.
I have never done programming in MFC. So facing bit problem. Well firstly i would like to know whether in MFC we can drag and drop the tool bars...well i am trying to view design of the form but i dont see any option and i cant view it...
The project is created on earlier version of VStudio as i am using VS2005. Is there much difference ?
Because i am getting few exception when i run this project on vs2005.
OK secondly when i am trying to step through this mfc application . After pressing F10 i get the appmodul.cpp file and it just step through one or two lines and run the whole application. How can i step through the whole program...Break point isnt helping me out.
Thirdly i have got this function class_def::abc(CProgressCtrl *pp) to get the progress bar working with addition of SetRange, SetStep and SetPos functions.
In Borland there is this TProgressBar option i guess. But if i just write TProgressBar in place of CProgressCtrl i get error i.e.[ } expected]. And what replaces the SetRange,SetStep, and SetPos functions...
Any or all help would be greatly appreciated.
Thanks
SS
|
|
|
|
|
VC6 -> VC2005 is a huge difference, VC6 was not very standards compliant at all. MFC has not changed that much, however.
Software_Specialist wrote: How can i step through the whole program...Break point isnt helping me out.
Run in debug mode ?
Software_Specialist wrote: But if i just write TProgressBar in place of CProgressCtrl
Obviously if they are different classes, they will expose different methods and you will get errors.
Moving from one framework to another is essentially a rewrite.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i am using picturebox to create visual buttons, but i want the picturebox has tabstop property, how can i do?
any api function ??
|
|
|
|
|
Try overiding the WM_GETDLGCODE message of the picture box and return DLGC_WANTTAB.
nave
|
|
|
|
|
i am gladly pleased you
|
|
|
|
|
In Test.exe module the application class CTestApp was derived from CWinApp . Everything worked fine. Then I decided to move some common stuff from CTestApp to CCommonApp . This CCommonApp is defined in Util.dll module. Now CTestApp is derived from CCommonApp which is derived from CWinApp .
The contructor of CTestApp is called properly and all its parent contructors. However the application crashes right after this, because the AfxGetApp returns NULL in MFC core and can't call InitApplication method.
Any idea what can be the problem?
Thanks, Abyss
|
|
|
|
|
You'll still need a global app object in the EXE project, something like:
// The one and only CTestApp object
CTestApp theApp;
If you already have that...
How is CCommonApp declared? It should be like this:
class AFX_EXT_CLASS CCommonApp : public CWinApp
{
...
};
Your DLL needs to be a legitimate MFC extension DLL as well.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks for advice.
I have this global application object in EXE. My DLL is also a dynamic DLL, where the CCommonApp is exported using __declspec(dllexport) and imported in EXE using __declspec(dllimport) .
I'm not sure what did you mean by legitime MFC extension DLL.
My Util.dll project has its own CUtilApp : CWinApp class, and _USRDLL define in project settings. Also tried to use DllMain method with _AFXEXT define. It did not help .
Maybe something is wrong with project settings, maybe something else. But I have no idea what could be wrong.
Thanks, Abyss
|
|
|
|
|
Abyss wrote: I'm not sure what did you mean by legitime MFC extension DLL.
See Extension DLLs[^]
Classes derived from MFC classes in a DLL and then derived from in an EXE means the DLL MUST
be an MFC extension DLL. MFC requires certain initialization in DllMain() and import/export
properties on classes must be dealt with. It's all documented at the link (and sublinks) above.
Also important - you can't statically link to MFC libraries - the DLL and the EXE need to use the
shared MFC DLL library.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Well, I tried to generate these two projects from scratch using VS Wizard. The EXE application is a simple MFC non doc-view architecture module. The DLL is a MFC Extension module. I added my CCommonApp class to the DLL and exported using AFX_EXT_CLASS macro. In EXE I replaced CWinApp with CCommonApp .
The result is the same
Now I would say that this is not supported. However I can remember that in the past I saw several projects where it worked well (unfortunately I can't find them)...
Any help is appreciated.
Thanks, Abyss
|
|
|
|