|
Hi all,
I would like to be able to turn off/on the monitor programmatically.
In fact, I can do that with this piece of code:
HWND hWnd = GetSafeHwnd();
::SendMessage(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
The problem is when the mouse is moving, the display is turning on back.
I tried to use a global mouse hook (implemented in a DLL) which is called and enabled by my main MFC application. The hook works great !
Then, in my application, I have this :
InstallHookMouse(); // Install mouse hook which lock all mouse messages
DisplayOff(); // Turn off the monitor
When I move the mouse while the display is turned off, it turns on back.
Have I to program a mouse filter driver to lock definitively this mouse and then, the monitor will not turn on back (until my application will decide to turn it on), or is there another solution ?
Thanks.
|
|
|
|
|
hkulten wrote:
The problem is when the mouse is moving, the display is turning on back.
When I move the mouse while the display is turned off, it turns on back.
If you turn the monitor off programmatically, how is it expected to turn back on other than via the mouse or keyboard?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
That's right. I badly expressed myself.
As the same way I can turn off the display programmatically, I will turn it back on programmatically. I don't want the user can turn on the screen. That's why I tried to lock mouse moves, but it does not work.
Any solution(s) ?
|
|
|
|
|
Unless you can convince me otherwise, I consider that to be very non user-friendly. If I'm working on the computer and some application decides that the monitor needs to go off and I can't turn it back on by moving the mouse, I would seriously consider removing that application.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yes, you're right for this point, but my application is targeting PC which displays multimedia messages on screens (LCD or Plasma) and, normally, there are no interactive users on these machines.
My application must turn off/on screens when no messages are displayed in order to save LCD/Plasma life time. My solution works well because, for that kind of PC, there are no users, but I want to develop my application properly, and I cannot accept that the screen could turn on without my application.
Maybe this is not possible on Windows platform to turn off properly the screen.
The last thing I would say is that I could do that on Atari ST platform, and fifteen years later, I could not do the same thing on Windows platform fifteen years old ?!! I think this is the progress...
Thanks for your response.
|
|
|
|
|
hkulten wrote:
::SendMessage(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
the SC_MONITORPOWER doesn't really turn the monitor off, it only make use of the power-saving feature of the monitor ( just like the screensaver does )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Yes you are right, but my purpose is to use this power-saving feature from my application. I want to be able to turn on/off monitor when I need, and no turn back on of the display when the mouse is moving.
Maybe are there softwares which can do that ?
Thanks.
|
|
|
|
|
Does anyone know how to hook a game engine? Or where to find the full source to the unreal Game Engine in C++?
|
|
|
|
|
Try posting this at
www.gamedev.net[^]
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
for game hacking this is the wrong address. I propose cheating pages!
Don't try it, just do it!
|
|
|
|
|
CopyFile("c:\\boot.ini","\\\\127.0.0.1\\e:\\boot.ini",FALSE);when I use the copyfile function after I have established a ipc$ connection with the target machine which I'd like to copy file to ,I receive a error code 67(using getlasterror),the error remains even when I change the ip address of the targe machine,and I think there is no syntax error ,what's the reason?
|
|
|
|
|
I've not tried this before, so this is just a guess, but shouldn't e: be mapped to a server\share on the target machine? In other words, if e: were mapped to \\127.0.0.1\someshare, then the target would simply be e:\boot.ini. Yes?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I inject a mfc dll inside a process, after i create a windows a windows using CWnd::CreateEx inside CWinApp::InitInstance but when InitInstance finished my windows is closed. I tried to solve this problem creating a new thread and inside this thread a create my windows but when i call CWnd::CreateEx my process crash. how can i solve this problem? how can i create a new windows in a MFC Dll injected inside another process?
|
|
|
|
|
Check this article
http://www.codeproject.com/system/hooksys.asp[^]
(Check the code near CreateRemoteThread)
How are you creating you window? on the stack or on the heap?
And what functions are you using to allocate memory?
(Consider VirtualAllocEx family of API)
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thks but i resolve the problem, its a bug of MFC, i resolve with this code (its a test code that i create it)
<br />
CMsnNvHookApp theApp; <br />
<br />
DWORD WINAPI ThreadStart (LPVOID dwThreadId) { <br />
::Sleep(300); <br />
<br />
AFX_MODULE_STATE *ModStat; <br />
<br />
ModStat = AfxGetStaticModuleState(); <br />
ModStat->m_pCurrentWinApp = &theApp; <br />
ModStat->m_hCurrentInstanceHandle = ::GetModuleHandle(NULL); <br />
<br />
AFX_MANAGE_STATE(ModStat); <br />
<br />
theApp.m_hThread = ::GetCurrentThread(); <br />
theApp.m_nThreadID = m_nThreadID; <br />
theApp.m_hInstance = ::GetModuleHandle(NULL); <br />
<br />
CFrameWnd *MainWin = new CFrameWnd(); <br />
<br />
MainWin->Create(NULL,"Prueba"); <br />
MainWin->ShowWindow(SW_SHOW); <br />
<br />
theApp.m_pMainWnd = MainWin; <br />
<br />
theApp.Run(); <br />
<br />
return TRUE; <br />
} <br />
<br />
BOOL CMyApplication::InitInstance() <br />
{ <br />
DWORD dwThreadId; <br />
<br />
::CreateThread(NULL,0,ThreadStart,0,0,&dwThreadId); <br />
<br />
return CWinApp::InitInstance(); <br />
}<br />
<br />
And i use a inject library called madCHook.dll <a href="http://www.madshi.net/">http:
|
|
|
|
|
I am practising writting a windows application purely by hand and by using windows API , as I am a beginner in windows programming and want to do some studying.
In almost all the explanations to the provided facilities, I find in the header section such statements as "declared in..., include windows.h", so I thought the facilities would be availabe so long as windows.h was included.
But that immediately proved wrong in compiling.
Yet more embarrassing is the function WinMain, I wrote it with returning type int, as is stated in MSDN, but the compiler(VC 6.0)reported errors for this.
Can you tell me how I can use the API functions and how to handled this problem?
Thank you for any help!
|
|
|
|
|
Well it would help if you listed the errors.
Have you tried using the AppWizard to generate a Win32 Application. This will help you to understand what is needed to create a pure Win32 app.
If you want to learn about the make-up of a Win32 app, I recommend this book[^]
Michael
CP Blog [^]
|
|
|
|
|
Thank you for your help!
I debugged the program again and solved some of the problems by myself. But the following one is really puzzling:
VC6.0 reported after compiling:
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
The WinMain function is written as follows:
int _stdcall WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
//register the window class and carry out things like that
}
I used the appWizard to create a win32 application and all the problems were gone. However, I still don't understand why the error was reported. _main is not defined in the win32 application either.
Thank you for all your help!
|
|
|
|
|
See if MSDN article Q291952 is of any help.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Just wanted to say thanks for posting this! I ran into the same problem and the article solved it for me! Thanks!!
Mike Ellertson
|
|
|
|
|
hey, just a tiny problem:
i use a CDialog with a couple of CustomCtrls arrange vertical. My CustomCtrl uses a CToolTipCtrl to display ctrl states.
When the Tooltip appears the control "under" the tooltip would not be repainted up to to the time the dialog call invalidate or the control gets the focus.
How can I solve that problem?
|
|
|
|
|
Hi,
I want to open multiple childs windows inside one of the childframe window of an MDI application. Any idea about how to achieve this?.
Details is like below:
I have my mainframe window derived from CMDIFrameWnd. Now in one of the childframe ( derived from CMDIChildWnd ) I want to open mutiple child windows i.e my child frame should behave as a parent to another child windows. Please let me know how to achieve this.
Any sample would be of great help.
Thanks,
Amit
|
|
|
|
|
The classic point to create child windows would in your CChildFrame::OnCreate handler.
I know the CSplitterWnd stuff goes there. You can also add toolbars etc at that point.
Iain.
|
|
|
|
|
Have a wierd one. One of our customers recently purchased a new computer with XP PRO installed. Out software prints fine on others customer's pcs running XP PRO, but this one wants to print everything upside down and backwards. Has anyone ever seen this happen. Would appreciate anyone's input.
Walt McWhirter
Compact Communications Systems
|
|
|
|