|
Can you post some code?
Steve
|
|
|
|
|
Here is some part of my code
// get the desktop window
// we assume the desktop window is never null and never iconized
IntPtr DTwnd = User32.GetDesktopWindow();
// taskbar window
IntPtr TaskBarhwnd = GetTaskbarWindow();
//initialize the window handle to null(zero)
IntPtr hwnd = DTwnd;
//get foreground window
IntPtr FGhwnd = User32.GetForegroundWindow();
// my current location
Point CurrentLocation = new Point(this.Location.X,this.Location.Y);
// set the new FG window as holder window
hwnd = FGhwnd;
User32.RECT windowRect = new User32.RECT();
// get foreground/desktop window location
User32.GetWindowRect(hwnd,ref windowRect);
Regards,
Hemant.
|
|
|
|
|
This doesn't look like unmanaged C++! Still, I can't see any context menu's here. Are you sure you're measuring what you think you are?
Steve
|
|
|
|
|
Hi,
Yes. This is C# code calling the Win32API
This code is called every 50ms by a timer where is finds the foreground window and moves the C# Form to the new location.
But when uses right clicks on any icon in system tray the foreground window position returned by GetWindowRect is incorrect.
Any guss why if givers wrong values?
Regards,
Hemant.
|
|
|
|
|
Try to find which window the HWND you're passing to GetWindowRect belongs to. One technique is to is to log the window class using the GetClassName API and the window text using the GetWindowText API. Another approach is the log the HWND values and look up the window using a utility like Spy.
Steve
|
|
|
|
|
how can we access smart technology of hard disk
|
|
|
|
|
Please ask it in the C#[^] forum. This is the Visual C++ forum.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Wrong forum
|
|
|
|
|
Dear All,
I want to write one COM with ATL Executable program or Service program.
Can one help me to get one exact easy article to do this ?
Kindly...
|
|
|
|
|
Please check this link http://www.codeproject.com/com/COM_EXE_Server.asp
Hoping that is the one you need
Rinu Raj
|
|
|
|
|
Did you see Sections on codeproject?
|
|
|
|
|
Hi all,
Can anyone knows how can i get virtual memory usage of a process in my c++ code,any api??
I am able to get physical memory usage of process in my code but not able to get information about virtual memory
Any help??
Manish
|
|
|
|
|
|
Thanx john
Its a total size of virtual memory allocated to a process but i want virtual memory currently being used by the process.
Do you knows anything about how can i get that information??
Manish
|
|
|
|
|
Total usedVirtual for a proccess = dwTotalVirtual - dwAvailVirtual;
John
|
|
|
|
|
Thanx John
I think that ll solve my querry...
Manish
|
|
|
|
|
If you can not get the information from GlobalMemoryStatus that you need you can also use VirtualQuery which will allow you to count all used memory blocks in a programs addresss space yourself. I actually have a need for both in the appilcations I write because of address space fragmentation the total amount of virtual memory free for a process may not be the amount of memory I can allocate given that I am allocating 16 to 60MB buffers.
BTW - I can give you an example code on this when I get to work if you need.
John
|
|
|
|
|
Hi John,
I m satisfied with the virtual memory usage shown by GlobalMemoryStatus function previously i had used that function but it gives me a look of total virtual memory allocated to all running proceses.
VirtualQuery needs Pointer to the base address of the region of pages to be queried from where i can get that? Coz i haven't allocated virtual memory by VirtualAlloc.
As u said you have a sample example of ur own may be it will help a little.
Thanx
Manish
|
|
|
|
|
Do you still need this? I can email you this as it is too long to post here.
John
|
|
|
|
|
Thanx John!
For the time i don't need to look on virtual memory usage but may be in future i required that.
U can mail me at mmanish3214@rediffmail.com
Manish
|
|
|
|
|
The problem with the code I promsed you is that it is part of a dll (that has over 50K lines of code) and uses a few other classes of the dll. For your purpose these are not necissary so giving you this code requires a little bit of cleanup which I have no problem doing however I am seriously behind a deadline at work. I have been working 12 hour days and although I really try to help others I really can't find the time. Sorry but I will get back to this I promise.
John
|
|
|
|
|
No probs John!!!
I required that just for an alternative to my previous code,whenever u get time do that or evenif not posible dnt worry i got my problem solved.
Manish
|
|
|
|
|
And seehere[^] maybe its some helpful for you
|
|
|
|
|
Is there any way I can access the return address to which control will go when my function returns?
To develop some debugging instrumentation, I would like some of my functions to be able to see where they have been called from. Is there some simple assembly language involved, perhaps, that would allow me to see this address?
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
One way (assumes 32bit x86):
#pragma optimize("y", off)
void Function()
{
DWORD ReturnAddress;
__asm
{
mov eax, [ebp+4]
mov ReturnAddress, eax
}
}
#pragma optimize("", on)
Or if your your compiler supports it use the _ReturnAddress intrinsic function.
Steve
|
|
|
|