|
|
I am totally new to .NET. Here ia a stupid question:
why I can not include <ofsteam> and <ifstea> ? I have the full .NET 2003 package on my machine.
thanks
|
|
|
|
|
I wrote a console application in Windows XP Visual C++ 6.0 and sent it to someone running Windows 2000 but it wouldn't run. An error box poped up saying The dynamix link library MFC4rD.DLL could not be found in ...
Is this a known problem? Is there any hope for me?
|
|
|
|
|
You sent the person a debug build (which requires MFC42D.dll). Rebuild the application in release mode and ship that version (which will require MFC42.dll, which in all likelihood already exists on their system).
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
An an aside to Ravi's recommendation, if you switch the project to use MFC in a static library, you won't need to ship any MFC DLLs at all.
|
|
|
|
|
Thank you both for your help.
|
|
|
|
|
Hi there,
I need to delete the Options menu during run-time. Currently it deletes it when the application first starts up. Then as I open up other CMultiDocTemplate windows, it reappears. These are the two functions I have in the CMainFrame class. I called the OnChangeFileMenu() function within the application class in InitInstance(). I thought that would do the trick but somehow it reappears as I open up other modal windows.
void CMainFrame::OnChangeFileMenu()
{
CWnd* pMain = AfxGetMainWnd();
// Get the menu from the application window.
CMenu* mmenu = pMain->GetMenu();
int pos = FindMenuItem(mmenu, "&Options");
if (pos > -1)
mmenu->RemoveMenu(pos, MF_BYPOSITION);
pMain->DrawMenuBar();
}
int CMainFrame::FindMenuItem(CMenu *menu, LPCTSTR menustr)
{
ASSERT(menu);
ASSERT(::IsMenu(menu->GetSafeHmenu()));
int count = menu->GetMenuItemCount();
for (int i = 0; i < count; i++)
{
CString str;
if (menu->GetMenuString(i, str, MF_BYPOSITION) &&
(strcmp(str, menustr) == 0))
return i;
}
return -1;
}
Besides inserting the below code in InitInstance, I also included it in the document view class's OnInitialUpdate:
// Get MDI Frame window
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
#ifdef MODE_1
pMainFrame->OnChangeFileMenu();
#endif
That did the trick for only one document view class but not others. It does not detect the presence of the menu when it's called yet it reappears afterwards. How can I remove it completely without having to insert the above code in numerous places. It should have taken care of it in InitInstance(). Thanks.
|
|
|
|
|
I had a similar issue, but I took care of it by only having one menu. When no document is loaded,
a lot of the menu items are gray... But my application only deals with one type of document, so
that solution may not be suitable for you.
Iain.
|
|
|
|
|
I was trying to avoid having to create a second menu with the item removed but in the end I chose that route. So in InitInstance, one of the menus will appear according to my criteria. Thanks for responding though.
|
|
|
|
|
I am trying to hook to a process.
i use "CreateProcess" method to create process as WinWord.exe, MSPaint.exe
etc....
then i use a hooking (using SetWindowsHookEx method) with the call
WH_CBT and in the proc i try to catch HCBT_CREATEWND and see if it is the main window.....
this all means that i need to hook the creation of the process i have just created and retrieve a handle HWND to its main window
it works ok with MSPaint but for word and excel and power point for example, it don't work at all....it seems that the hook occurs right after the main window was already created that is why the message WM_CREATE never cought....
can any1 help?
am i doing it wrong? is there a better way?
10x in advanced
Yaron
|
|
|
|
|
Im using MFC to make dailog based program.
I have one button that will change my start button text to "TEST" after click.
my program crash after I clicked on the button
here is the code for the button.
void CStart_Button_ChangerDlg::OnText()
{
HWND starthandle;
CWnd StartButton;
CWnd* Window = CWnd::FindWindow("Shell_TrayWnd","");
starthandle = FindWindowEx(NULL,NULL,"Button","");
StartButton.m_hWnd=starthandle;
StartButton.SetWindowText("TEST");
StartButton.SendMessage(WM_SETTEXT,0,0);
//SendMessage (StartButton, WM_SETTEXT, 0);
}
|
|
|
|
|
|
Mouse_103 wrote:
...change my start button text to "TEST"...
See here on how to do this.
Mouse_103 wrote:
starthandle = FindWindowEx(NULL,NULL,"Button","");
StartButton.SetWindowText("TEST");
Should be:
starthandle = FindWindowEx(Window->GetSafeHwnd(),NULL,"Button",NULL);
::SetWindowText(starthandle, "TEST"); However, this will not work as intended as the Start button's text is not drawn in the normal fashion.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
--------------------Configuration: Start_Button_Changer - Win32 Debug--------------------
Compiling...
Start_Button_ChangerDlg.cpp
C:\-= My Stuff =-\Start_Button_Changer\Start_Button_ChangerDlg.cpp(186) : error C2660: 'SetWindowTextA' : function does not take 2 parameters
Error executing cl.exe.
Start_Button_Changer.exe - 1 error(s), 0 warning(s)
|
|
|
|
|
The compiler is telling you exactly what the problem is. You are trying to use CWnd::SetWindowText() which does not take 2 parameters.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I got it working now
now Im trying to get working with the user defined edit box.
I use control CEdit for the edit box.
void CStart_Button_ChangerDlg::OnText()
{
HWND hWnd;
RECT rc;
if (hWnd = FindWindowEx(NULL, NULL, "Shell_TrayWnd", NULL)) {
::GetWindowRect(hWnd, &rc);
if (hWnd = FindWindowEx(hWnd, NULL, "Button", NULL)) {
/*
CEdit* text = (CEdit*)GetDlgItem(IDC_EDIT1);
CString gettext;
text->GetWindowText(gettext);
*/
CString starttext;
m_text.GetWindowText(starttext);
::SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)(LPTSTR) TEXT(starttext));
}
}
}
compile error:
Compiling...
Start_Button_ChangerDlg.cpp
C:\-= My Stuff =-\Start_Button_Changer2\Start_Button_ChangerDlg.cpp(199) : error C2440: 'type cast' : cannot convert from 'class CString' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
Start_Button_Changer.exe - 1 error(s), 0 warning(s)
|
|
|
|
|
never mind
I got it working...
I had to change the LPTSTR to LPCTSTR
|
|
|
|
|
Hi everyone.
I'm writing a service that periodically launches a GUI program. I want to check to make sure someone is logged on to the computer before i launch the program so it can interact with the desktop. Is there any easy way to do this? Thank you very much.
Jay
|
|
|
|
|
How about NetWkstaUserGetInfo() ?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
if u use OpenInputDesktop() and it returns NULL then the interactive desktop is not available. ie: no-one is currently logged on or "using" the computer.
|
|
|
|
|
Hi,
I program with Visual C++ .NET 2003.
I have an application that I want to quit if a specific date is passed. (the user will not choose Quit in the menu)
I want to terminate the application in the OnClose member function of my CApplicationView class.
I have tried with various methods like PostMessage(WM_DESTROY, 0, 0) or PostQuitMessage(0) without success.
Does anybody have suggestions ?
Thanks,
Claude
|
|
|
|
|
|
|
The correct method is PostMessage(WM_CLOSE) .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
You can try PostMessage(WM_QUIT,0,0) too.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|