|
Hi,
What is the VC++ Substitute for the MFC <code>SetIcon</code> function??
Thanx in Advance
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I think you should look at DrawIcon() /LoadIcon()
SetClassLong(): Your application can replace a class icon by using the SetClassLong function.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Use the WM_SETICON message.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
For a static control, send it a STM_SETICON message. For a button, send it a BM_SETIMAGE message. For all others, send them a WM_SETICON message.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all,
How would I go about getting hold of the handle to the instance of the application.
<code>
HINSTANCE hInst
</code>
I know in MFC one would use <code>AfxGetInstanceHandle()</code> ,so what can I use in good old VC++?
Thanx in advance
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
what about first parameter of Winmain ? .
From MSDN;
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
);
|
|
|
|
|
Thanx for the response. The other question I have is:
<pre?
in mfc="" one="" would="" use="" <code="">SetIcon</code> to set the Icon, what can I use for VC++, <code>LoadIcon</code> ???
Thanx Again
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Here another way. The function GetHandleToModuleWhichContainsThisFunction returns the HMODULE of the module that contains it. It's better to use the value passed in WinMain but this technique come in handy from time to time.
#include <iostream>
#include <windows.h>
namespace
{
HMODULE GetHandleToModuleWhichContainsThisFunction()
{
HMODULE hMod = NULL;
const void *pFunc = &GetHandleToModuleWhichContainsThisFunction;
MEMORY_BASIC_INFORMATION mbi;
if ( VirtualQuery(pFunc, &mbi, sizeof(mbi)) == sizeof(mbi) )
{
hMod = reinterpret_cast<HMODULE>(mbi.AllocationBase);
}
return hMod;
}
HMODULE GetHandleToInstanceWhichContainsThisFunction()
{
return reinterpret_cast<HINSTANCE>(GetHandleToModuleWhichContainsThisFunction());
}
}
int main()
{
HMODULE hMod = GetHandleToModuleWhichContainsThisFunction();
using namespace std;
char Path[MAX_PATH];
GetModuleFileName(hMod, Path, sizeof(Path)/sizeof(Path[0]));
cout << Path << endl;
return 0;
}
Steve
|
|
|
|
|
Thanx Steve, I'll chech it out...
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Hi,
I am working in a project where I need to position my applications icon on active/Foreground window. It works well in all cases except when user right clicks on a icon in task bar system tray it get positioned to wrong place. When I debugged into code I found that the GetWindowRect function itself gives wrong values(like 0,0,123,34) for context menus. How can I solve this problem? Why GetWindowRect fails?
Regards,
Hemant Kulkarni.
|
|
|
|
|
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
|
|
|
|