|
pther wrote: How can I terminate the process
Although you can get the process id of window and call TerminateProcess() function, i dont recommand using it.
If the HWND is HANDLE to the main window of that application, seding a WM_CLOSE message will terminate the process.
|
|
|
|
|
But this methos is giving exception after closing the application so couls you tell me like Treminate process using HWND
|
|
|
|
|
Well, then you should fix the problem. Is it one of your application that crashes ?
TerminateProcess will kill the process in a brutal way, sending a WM_CLOSE message is much elegant because it lets the application do some clean-up before exiting.
|
|
|
|
|
pther wrote: Treminate process using HWND
1. GetWindowThreadProcessId() to get the process ID.
2. With this process id callOpenProcess() function with PROCESS_TERMINATE access.
3. Call TerminateProcess().
|
|
|
|
|
You dont need to use of Treminateprocess you must send WM_CLOSE for close a program.
|
|
|
|
|
Dear Friends,
I want to split List control into groups at run time similiar to
Windows VISTA MY Computer view.
i.e. 1) I can expand and collapse the items at run time ?
2) Header of groups should be in user defined color etc.
Any help is highly appreciated.
I am developing the MFC application in Visual Studio 2008 + feature
pack 1.
Thanks,
Subhash Madhukar 
|
|
|
|
|
hi
please explain more clear ..
|
|
|
|
|
Hi,
Thanx for reply.
Can u pls provide ur email id. so that I can send the snapshot of my requirment.
Thanks,
Subhash
|
|
|
|
|
hi,
this is basha, i don't how to convert money into alphabets in vc++.
Requirements ( visual c++)
1.it will accept all type money range
( one ,ten ,.......billion,million,etc.......)
2.the code will convert money(Rupees and paise format)
3.while enter the value in textbox,after that we press dot. it will allow only two digit.
|
|
|
|
|
ammaappa wrote: while enter the value in textbox,after that we press dot. it will allow only two digit.
The Ultimate Toolbox Masked Edit has more than you need[^]
ammaappa wrote: 1.it will accept all type money range
( one ,ten ,.......billion,million,etc.......)
2.the code will convert money(Rupees and paise format)
It seems you never want to be a programmer, anyway have a look at this repository[^]
|
|
|
|
|
Sounds like a university project....
Anyway, what have you tried so far ?
|
|
|
|
|
I wrote a program in C++ MFC and create 2 more thread , this program ryn on several computers .
recently I bought a new PC and the program can’t create more then one thread .
The same program work nice on other PCs.
All the PCs run WINDOWS XP PRO.
|
|
|
|
|
Did you read the "How to get an answer to your question" sticky post at the top of this board?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Then try debugging it, you will never learn otherwise.
Also, we can't help if you don't give us any details.
|
|
|
|
|
I need to change printer default settings. I am using DocumentProperties function. Here is my code:
if(!SetDefaultPrinter(ptiSel.sPrinter)) return false;
HANDLE hPrinter;
if(!OpenPrinter(ptiSel.sPrinter.GetBuffer(0),&hPrinter,0)) return false;
DWORD dwSize = DocumentProperties(0,hPrinter,ptiSel.sPrinter.GetBuffer(0),0,0,0);
pDefDEVMODE = (LPDEVMODE) malloc(dwSize);
DocumentProperties(0,hPrinter,ptiSel.sPrinter.GetBuffer(0),pDefDEVMODE,0,DM_OUT_BUFFER);
if(pDefDEVMODE->dmFields & DM_DEFAULTSOURCE)
pDefDEVMODE->dmDefaultSource = ptiSel.wTray;
DWORD res=DocumentProperties(0,hPrinter,ptiSel.sPrinter.GetBuffer(0),pDefDEVMODE,pDefDEVMODE, DM_OUT_BUFFER | DM_IN_BUFFER);
if(res != IDOK) MessageBox(0,_T("Could not set printer settings"),0,MB_ICONERROR);
ClosePrinter(hPrinter);
This code is based on msdn sample (http://support.microsoft.com/kb/167345). Settings are not changed. The second call of DocumentProperties retrieves valid DEVMODE structure, I change it and save back to printer, the function returns IDOK result but does not write settings to printer. Can anybody help me?
|
|
|
|
|
|
Thanks. Is ther any way to change printer defaults for all applications?
|
|
|
|
|
Hi,
I have a few thread questions
Would anyone know why someone would use _beginthreadex instead of CreateThread or visa versa
What is the difference between The Value return from GetCurrentthreadId and GetCurrentThread
In processing my DLL ATTACH_THREAD message I am able to get the threadid of the thread being created but not the thread
handle The GetCurrentthread API returns -1
Can I get the Thread handle if I have the the thread id
Thankx
|
|
|
|
|
ForNow wrote: _beginthreadex instead of CreateThread or visa versa
_beginthreadex() internally calls CreateThread for creating thread. In addition to creating thread, it will perform some CRT initializations also. So if you want to call some CRT functions inside the new thread, its better to use the _beginthreadex() function.
ForNow wrote: The Value return from GetCurrentthreadId and GetCurrentThread
GetCurrentthreadId return the current thread ID where GetCurrentThread return the handle to current Thread.
ForNow wrote: handle The GetCurrentthread API returns -1
If you call the GetCurrentthread(), it will always return 0xfffffffe. Actually this is a pseudo handle to the current thread. This value can be used only in that thread. The GetCurrentProcess() also returns a similar value - 0xffffffff.
If you want to get the correct handle value, you need to use the DuplicateHandle() function
HANDLE hRealHandle = 0;
DuplicateHandle( GetCurrentProcess(),
GetCurrentThread(),
GetCurrentProcess(),
&hRealHandle,
0,
TRUE,
DUPLICATE_SAME_ACCESS );
|
|
|
|
|
|
If a message is simulated using SendInput(), is there a way in themessage handler to detect the simulated events?
For instance, if someone uses SendInput with MOUSEEVENTF_LEFTDOWN over my window, is there any way to know or are those messages indistinguishable?
|
|
|
|
|
Unfortunately you are correct that those messages are indistinguishable. SendInput() inserts the input messages directly into the kernel input stream. You can read one of my prior posts[^] regarding how SendInput is actually invoking a privileged system call. [^]
If there is a security reason as to why you want to block this function then the only way I can think of is a driver implementing a SYSENTER hook[^].
Best Wishes,
-David Delaune
|
|
|
|
|
Interesting.
I was afraid there wasn't a way to differentiate those.
Thanks for taking the time to assist.
|
|
|
|
|
Hello.
I am having trouble capturing the mouse wheel messages. Everything works except when WM_MOUSEWHEEL is called, the HIWORD of wParam (combination of WHEEL_DELTAs, positive value means wheel is moved away from the user, negative is towards) is always 0. What is the problem? I am using Visual Studio 2003 btw.
// mousehook.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "mousehook.h"
#define MAX_LOADSTRING 100
HHOOK MouseHook;
static LRESULT CALLBACK MouseProc(UINT nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode < 0)
{
CallNextHookEx(MouseHook, nCode, wParam, lParam);
return 0;
}
int zDelta = ((short)HIWORD(wParam));
if(wParam == WM_MOUSEWHEEL) // This is called properly. I need to know which way the wheel moves, but zDelta is always 0. What could be the problem?
{
}
return CallNextHookEx(MouseHook, nCode, wParam, lParam);
}
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
MouseHook = SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)MouseProc, hInstance, 0);
MessageBox(0,"Press ok to unhook","Hooked",0);
UnhookWindowsHookEx(MouseHook);
return 0;
}
I would really appreciate it if someone helped me..please.
|
|
|
|
|
how can wParam be equal to WM_MOUSEWHEEL and, at same time, give you meaningful info about wheel delta?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|