|
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
|
|
|
|
|
I am writing a real-time communication software whit VC++7 (App Type is Win32 Console)this is my first experince whit SQL in a heavy program.
I Open DataBase with CDataBase.OpenEX() in the beginning of program and Close it in the end.This program must run for several days or weeks each time and in each second i makeseveral transactions using CDataBase.ExecuteSql() and CRecordSet.GetFieldValue()
My Question Is, Can I Depend on Validity of Sql Connection for several days(I Guess not!),If not What Kind of Handling Required?
I can Not Open and Close DataBase each Time ineed it, Because of Real Time feature of
My Program.
Yours, Mehrdad
|
|
|
|
|
I don't think you can count on the connection remaining open for that long a period if the app is on a different machine than the database. what I did in one of my apps was to check for that specific error that indicates the connection is not open, then try to re-open the connection without sending the user any indication. if the re-open fails, then I let the error message continue as usual
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
how to typecast unsigned int(void *) to unsigned int64?
Please help me.
Heaven's on me
|
|
|
|
|
i'm not sure i understand you.
what does a void* make here ??
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi,
I have an ATL COM object with DECLARE_CLASSFACTORY_SINGLETON
is there a way to access the singleton instance inside the serverdirectly?
(currently I'm using CoCreateInstance, but the registry/DllGetClassObject round trip seems not necessary)
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
I created two static horizontal panes using CreateStatic() function of CSplitterWnd class. The view class of the top pane is derived from CView and the bottom pane from CScrollView. The message mapping of the menu items is performed in CMainFrame as it cannot be done directly from both the view classes(Atleast it seems like that). The problem is wheni call Invalidate(TRUE) in one of the functions of the View class it gives a runtime error.
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT ,<br />
CCreateContext* pContext)<br />
{ <br />
VERIFY(m_wndSplitter.CreateStatic(this, 2, 1));<br />
<br />
VERIFY(m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CTitleView),<br />
CSize(100, 100), pContext));<br />
VERIFY(m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CTrialView),<br />
CSize(100, 100), pContext));<br />
m_wndSplitter.SetRowInfo(0,50,50);<br />
return TRUE;<br />
}
As u can see from the above code i created a splitter window. CTitleView is derived from CView and CTrialView from CScrollView.
void CMainFrame::OnFileOpen() <br />
{<br />
m_pTrialView.OnFileOpen();<br />
}
m_pTrialView is an object of CTrialView. It is used to call the function FileOpen in CTrialView.
void CFaceRecognizerView::OnFileOpen()<br />
{<br />
Invalidate(TRUE);<br />
}
void CFaceRecognizerView::OnDraw(CDC* pDC)<br />
{<br />
CFaceRecognizerDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
if(flag==1)<br />
AfxMessageBox("HI");<br />
}
This is where the error comes. My aim is to access the OnDraw() function. Hopw someone can help me out of this
|
|
|
|
|
When working with Doc/View framework, is it better to call UpdateAllViews from doc objects instead of trying to repaint views themselves.
Jaime
|
|
|
|
|
hello everyone
i wanted to know what exactly is the .hh file formats.are they the header file extensions.
one can see a lot of these files used like header files for the cpp files
this website has programs which use these file formats.
http://www.mip.informatik.uni-kiel.de/~wwwadmin/Software/Doc/BIAS/html/files.html
|
|
|
|
|
looking at their content, it seems that they are headers to...
moreover, you can find such code lines, that explicit what i thought :
#include <Base/Debug/Error.hh>
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
why would one use such an extension when we have a .h extension header ?
|
|
|
|