|
Hi,
I need to create a text field within a dialog box, where i want some data to be printed out (i.e., to show) .
How do I start ?
Thanks,
Deepak Samuel
|
|
|
|
|
I assume you already have a dialog working.
Got to the resource editor and add a static text control. Its ID is going to be IDC_STATIC change that to your own ID. Like IDC_MYTEXT. What you put as the text of the static control is going to be the text that is initially displayed.
Now, in one of your dialog message handler, wherever you want to change the text on the dialog, put the following:
CStatic* pText = (CStatic*) GetDlgItem(IDC_MYTEXT); //get a pointer to the control
pText->SetWindowText(“Hello World”); //set the text
When the message handler is called the text is going to change to Hello World.
This works with an edit box too. Make an Edit box on your resource template with ID IDC_MYEDIT. The following code will display the text.
CEdit* pEdit = (CEdit*) this->GetDlgItem(IDC_MYEDIT);
pEdit->SetWindowText("Hello World");
I hope this helps.
Lorenz Prem
Microsoft Corporation
|
|
|
|
|
You might want to consider using an EDIT control instead of a STATIC, and then set the ReadOnly property on it. The advantage is that users will be able to copy & scroll the data in the control. If you don't plan on displaying all that much data, then maybe the STATIC is the right way to go.
|
|
|
|
|
Jeez, even the guys at MS don't know about SetDlgItemText .
I don't know about you, but I find a one-liner much more readable:
SetDlgItemText( IDC_MYEDIT, _T( "Hello World" ) );
Also, there's no need to cast to a CEdit or CStatic pointer if you're just going to be calling a method implemented on CWnd.
|
|
|
|
|
I agree that your solution is much more elegant and readable, but getting a pointer to the control is also a vital step in many other not so basic scenarios.
I figure I better answer the question the way it is most useful, not necessarily in the shortest way. That includes the cast, which might be necessary for other things besides setting the text.
Lorenz Prem
Microsoft Corporation
|
|
|
|
|
Wow!!!
Lorenz Prem
Microsoft Corporation
Does that mean that we are getting an official MSFTs responce now?
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I try to create thread from thread under FMC.
But sometime it not work (hang).
Maybe someone did it before ???
brainiax@wp.pl
|
|
|
|
|
Post the code that spawns the thread inside another thread.
Kuphryn
|
|
|
|
|
Hi!
I write a console execute in vc. It is called by other command line. How can i make vc ide into debug it when it is been called? How can set a break in some lines?
I believe it is definitely possilbe in vc, but i don't know how to operate.
Thanks!
|
|
|
|
|
To my knowledge, Visual Studio must start the application in order to debug it.
|
|
|
|
|
put __asm{ int 3 }; at the beginning of the code!
when the exception is raised, attach visual studio debugger to it, voila
Don't try it, just do it!
|
|
|
|
|
I am conecting to MYSQL database which is on the server using following code.
CDatabase m_dbftp;
m_dbftp.OpenEx(sDSNName,CDatabase::noOdbcDialog | CDatabase::useCursorLib );
Connection is done properly. I want to catch the exception
when server is disconnected.
I am using following code
catch(CDBException* pEx )
{
CString sz;
if ( pEx->m_nRetCode == AFX_SQL_ERROR_CONNECT_FAIL )
AfxMessageBox("myconnection failed");
}
It dose not work
Problem is m_nRetCode contains -1 instead of
AFX_SQL_ERROR_CONNECT_FAIL .
I am not able to identify if server is disconnected .? How to do it.
|
|
|
|
|
I see a sentence like below:
private Mutex[] m_mutex;
It seems very strange for me
What is its meaning?
Help
Thank you
|
|
|
|
|
Short for MUTual EXclusion. These are used to non-recursively synchronize access to shared resources. Eg: in order to protect a critical section, you can use a mutex, which will ensure that only one thread at a time can lock it.
|
|
|
|
|
It looks like a syntax error to me. The private keyword should have a colon after it, and the square brackets should follow the variable, not the type.
private:
Mutex m_mutex[];
If it's something different, it's new to me.
|
|
|
|
|
DavidCrow wrote:
It looks like a syntax error to me. The private keyword should have a colon after it, and the square brackets should follow the variable, not the type.
private: Mutex m_mutex[];
If it's something different, it's new to me.
I think that's Java, or may C#. In Java, you denote the accessability of each member explicitly. Correct me if I'm wrong, its been a while since I used Java, arrays of a type are written as TypeName[] variableName.
|
|
|
|
|
|
You can find the codes at the following site:
http://www.codeproject.com/useritems/inprocsemaphore.asp?target=semaphore
|
|
|
|
|
Shouldn't C# questions be posted to the C# forum instead of the VC++ forum? You're bound to get more answers that way!
|
|
|
|
|
Is there any way to programatically set/unset fullscreen console mode?
Neil
|
|
|
|
|
hi..
this way is not exactly same yours however you can use.
<br />
void CMainFrame::OnViewFullscreen() <br />
{<br />
if (m_fullscreen)<br />
{<br />
ModifyStyle(0,WS_CAPTION|WS_THICKFRAME); <br />
ShowWindow(SW_SHOWNORMAL);<br />
<br />
ShowControlBar(&m_wndToolBar, TRUE, FALSE);<br />
ShowControlBar(&m_wndStatusBar, TRUE, FALSE);<br />
}<br />
else<br />
{<br />
ModifyStyle(WS_CAPTION|WS_THICKFRAME,0); <br />
ShowWindow(SW_MAXIMIZE);<br />
<br />
CFrameWnd* pChild = GetActiveFrame();<br />
if (pChild) pChild->ShowWindow(SW_MAXIMIZE);<br />
<br />
ShowControlBar(&m_wndToolBar, FALSE, FALSE);<br />
ShowControlBar(&m_wndStatusBar, FALSE, FALSE);<br />
}<br />
m_fullscreen = !m_fullscreen;<br />
}
|
|
|
|
|
Erm, I was after full screen mode for console (text mode) programs, not GUI
Neil
|
|
|
|
|
hm.. I never did it, but perhaps by finding the window of the
console. and then sending "Alt+Enter" to it?!?
Use EnumWindows(), So you can find the ConsoleWindow. it has
the name of your app in the title.
and then send the "go full screen" magic "Alt+Enter"
|
|
|
|
|
Functional but not very elegant - this sends a Ctrl+Enter to the console window:
<br />
#include <windows.h><br />
#include <conio.h><br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
keybd_event( VK_MENU, MapVirtualKey( VK_MENU, 0 ), 0, 0 );<br />
keybd_event( VK_RETURN, MapVirtualKey( VK_RETURN, 0 ), 0, 0 );<br />
keybd_event( VK_RETURN, MapVirtualKey( VK_RETURN, 0 ), KEYEVENTF_KEYUP, 0 );<br />
keybd_event( VK_MENU, MapVirtualKey( VK_MENU, 0 ), KEYEVENTF_KEYUP, 0 );<br />
<br />
<br />
getch();<br />
return 0;<br />
}
Displaced Aussie. Currently in London, normally living in Melbourne.
modified 10-Jul-19 21:02pm.
|
|
|
|
|
what is a SAFEARRAY?
I am having a hard time understanding the little documentation that I have found. I am interested in constructing one because of this function I have found...
<br />
int CFacedetectApp::RCobj_detectfaces(SAFEARRAY **bmp)<br />
{ <br />
BYTE *bmp2;<br />
int i;<br />
<br />
SafeArrayLock(*bmp);<br />
<br />
bmp2 = (BYTE *)(*bmp)->pvData;<br />
<br />
for (i=0;i<width*height*3;i++) video_image[flip]->imageData[i] = bmp2[i]; <br />
<br />
if (!trackingEnabled)<br />
DetectFaces(video_image[flip]);<br />
else<br />
updateTracking();<br />
<br />
flip = 1-flip;<br />
<br />
SafeArrayUnlock(*bmp);<br />
<br />
return(NoOfObjects);<br />
}<br />
The code is from....
http://www.fuzzgun.btinternet.co.uk/rodney/components.htm#FaceDetection[^]
Why is it so hard just to give a function a simple file name and let it do it's detection
I like his .dlls because they are simplified but I am having trouble understanding them. any help would be great. thanks
Later, JoeSox www.humanaiproject.org
"The worst fad has been these stupid little robots,
Graduate students are wasting 3 years of their lives
soldering and repairing robots, instead of making them smart.
It's really shocking." -Marvin Minsky.
|
|
|
|