|
Anonymous wrote:
I can't figure out how clear the question...
The question would be in an edit control. Use SetWindowText() and GetWindowText() accordingly.
Anonymous wrote:
...or to add possibly more or less radio buttons after the student clicks the next button.
Put the maximum number of radio buttons that will be needed on the dialog at design time. Show/hide them as needed throughout the quiz.
Anonymous wrote:
I also need to know how to size the window to match the screens resolution.
Normally, this is not necessary and doesn't fit the profile of a dialog. Anyway, ShowWindow(SW_SHOWMAXIMIZED); in the dialog's OnInitDialog() method will do it.
|
|
|
|
|
Radio buttons:
You could try placing the maximum number radio buttons that you would need on the dialog and then use ShowWindow() to show or hide them. You will also needed to use SetWindowText() (a.k.a. WM_SETTEXT) changed the text associated with the buttons depending on the question.
Give the buttons generic name line IDC_RADIO1, ID_CRADIO2, etc...
------------------------------------------
Sizing:
David Crow gave a good answer but I think you might want to go further than just maximizing the window. Search codeproject for resizable dialog box aticles. The reason I am sugesting this is that you may want the controls in your dialog box to adjust there size and position according to the size of the dialog box. Of course for such a simple program you may not care.
INTP
|
|
|
|
|
I am having problem with the dialog box
with CDataGrid. Once I open the dialog box and
close, I can't open it for the second time.
I think the problem is the way to initialize
and close the dialog box. I am supposed to do
something with CDataGrid?
Thanks in advance.
Shin
|
|
|
|
|
Hello,
I try to open a dialog with a custom control, calling the finction Dialog.DoModal(). The Function returns imediatly and the Dialog is not shown. (Returncode -1, GetLastError() 0)
If I start a new Dialog based MFC application, I can insert a custom control in the Dialog and the Application runs fine.
Compiler and Linker Settings seem to be the same in both projects.
I can use the custom control in my application in dialogs which are used as view in a splitter window.
Can anyone tell me whots going wrong an what I have to do to get the things running?
Regards
Bernd
|
|
|
|
|
Does it have anything to do with the control needing to be registered?
|
|
|
|
|
I don't think so. I steped through the code. The Custom controls classes are registered before the dialog is creaded.
The dialog has a membervariable of the custom controls type and if I step through the Constructor I can see when the Custom controls class is registered.
I steded through the DoModal() and somewhere in CreateDialogIndirect I get a fail. (code not available at the moment)
|
|
|
|
|
By registering, I meant using regsvr32.exe. I've not tried this via code.
|
|
|
|
|
The custom control is implementet in the application and not in a dll or something else.
I can use it the same way I tried it in ma Application in other sample programs without problems.
|
|
|
|
|
Iam new to programming in .NET's C++ and I am a little puzzeled on how to perform the following
Objective: I need to have a main PC communicate with to other PC's. The information I need from the additional PC's is what is currently running(i.e. windows programs, etc.) and send a message back. After that I need to have the main PC shutdown or shutdown/reboot the additional PC's and or the main PC
I know I know how to perform the Shutdown or shutdown/reboot.
How do I communicate with the other PC's to tell me what is running on them?
Is there anything that I can research which will help me?
Thank you for your help
|
|
|
|
|
You might use the windows performance monitor api. If you have used the windows performance monitor, you know that you can look at a report of what processes are running. Look at WMI.
Alternatively, rather than query for all that info and make a remote decision, why not signal a check on the computer to be shut down? You would write a service that would run on the shutdown-able PCs. There are multiple ways to signal the remote service, however since you probably are interested in signalling all such PCs, a mailslot (using a * for the coputer name) may be the easiest approach.
Obviously, I'm not providing details here, but direction for further research on your part.
tim
tim
Founder, TMurgent Technologies
www.tmurgent.com
tmangan@tmurgent.com
|
|
|
|
|
Hi,
I have a dialog who will contains other dialogs accessible by a CTabCtrl control.
When I click the tabs, I change the dialogs to display.
I want to display the dialogs in the tab control, under the tabs.
To do this I have to get the dimensions of the rectangle corresponding to the CTabCtrl itself minus the height of the tabs.
The problem is that I am not able to get the good position of the tab control.
I have to modify the position with number freeze in the code. I am not sure that it will be correct for all monitors.
The code is taken from the article "Creating a CTabCtrl Application" in CodeGuru.
Here is my code:
void CPref_04::SetRectangle()
{
CRect tabRect, itemRect;
int nX, nY, nXc, nYc;
m_TabPref.GetItemRect(0, &itemRect);
// uses GetDlgItem to return a pointer to a user interface control
CTabCtrl* pTab;
pTab = (CTabCtrl*) GetDlgItem(IDC_TAB_PREF);
pTab->GetClientRect(&tabRect);
nX = itemRect.left + 10; <----- number freeze in the code
nY = itemRect.bottom + 12;
nXc = tabRect.right - itemRect.left;
nYc = tabRect.bottom - nY + 10;
m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
for (int nCount = 1; nCount < m_nNumberOfPages; nCount++)
{
m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
}
}
Thanks for any help
Claude
|
|
|
|
|
Try getting the window rect and use ScreenToClient() if applicable.
Kuphryn
|
|
|
|
|
RECT r;
tabCtrl.GetWindowRect(&r);
tabCtrl.AdjustRect(FALSE, &r);
tabCtrl.ScreenToClient(&r);
or somethign along the lines... (I could dig up a project and look it up if this doesn't work as intended)
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Hi Claude,
I use this code to activate a page:
int
CDlgTabCtrl::SetActivePage( int iPage )
{
//Place the window top-left under the tab-control
CRect rect;
GetClientRect( &rect );
AdjustRect( FALSE, rect );
CRect rectTab;
GetWindowRect( &rectTab );
GetParent()->ScreenToClient( rectTab );
rect.top +=rectTab.top;
rect.left +=rectTab.left;
//verify parameters
if( iPage+1 > m_iPages )
{
iPage =0;
}
if( iPage < 0 )
{
iPage =m_iPages-1;
}
// get the actual page
CDlgTabPage* pPage;
pPage =(CDlgTabPage *)m_Pages.GetAt( m_iActivePage );
// deactivate it
pPage->ShowWindow( SW_HIDE );
HighlightItem( m_iActivePage, FALSE );
// get the new page
pPage =(CDlgTabPage *)m_Pages.GetAt( iPage );
//adjust the position and show it
pPage->SetWindowPos( NULL, rect.left, rect.top, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE );
pPage->m_pTabCtrl =this;
pPage->OnSetActive();
m_iActivePage =iPage;
HighlightItem( m_iActivePage, TRUE );
// set the CTabCtrl-element
SetCurSel( m_iActivePage );
SetFocus();
//OkeeDokee
return m_iActivePage;
}
Make sure to set the DS_CONTROL style to your dialog pages, makes life a lot easier...
dirk
|
|
|
|
|
I have wrote a simple keyframe grabber using the directX api that grabs a frame on time intervals,
Would any one know of a library or a way to determine when to grab a frame based on scene change? Any help or guide would really be a life saver!!
|
|
|
|
|
google for source code to video survaillence / webcam alarm systems etc or possibly look at delta error type stuff from a mpeg codec
|
|
|
|
|
Does anyone have any idea why VC 2003 .NET will not allow me to create a control variable for ComboBox in a secondary dialog (created using Add Resource) and activated using the DoModal function.
If I put the ComboBox in the main Dialog, I can create a control variable. I can create a control variable for it even if I put it in the ABOUT dialog. But for some reason, it simply doesn't like assigning a control variable to a ComboBox that is in a dialog that was created with the Add Resource function.
Anyone got any ideas?
Karen
|
|
|
|
|
Maybe the developer studio that you have has a bug. One solution is to add the control manually.
Kuphryn
|
|
|
|
|
How to copy and paste text in a cell in excell.
funtion _Application::GetSelection return what?
Help me please
|
|
|
|
|
Here's an example of how to set the value of an Excel cell:
if (app.CreateDispatch("Excel.Application") == TRUE)
{
app.SetVisible(TRUE);
books = app.GetWorkbooks();
book = books.Add(vtOptional);
sheets = book.GetSheets();
sheet = sheets.GetItem(COleVariant((short) 1));
range = sheet.GetRange(COleVariant("A1"), COleVariant("A1"));
range.SetValue(COleVariant(strText));
...
}
You should be able to ascertain from this how to get the value of a cell.
|
|
|
|
|
Thanks Mr David!
Yes, I know this. But May you help me how to copy text to clipboard?
In Word I do this:
_Application app;<br />
Range range;<br />
.....<br />
range.Select();<br />
Selection sel=app.GetSelection();<br />
sel.Copy<br />
sel.Paste <br />
<br />
In excel I see funtion app.GetSelection. But I don't know what object that is returned.
please help me.
Thanks
Jason Chang
tmsnhien@yahoo.com
|
|
|
|
|
I have a TCP server that uses two classes: a ConnectionManager and a DbgConsole. U can specify a parameter in console to turn on logging. It just outputs all its output through DbgConsole with a function called ConsoleOutput() which just couts a string to the console and if logging is enabled writes the string to a file. When logging is turned on, the DbgConsole class opens a new file and stores the file handle in a private member variable of that class. From then on the ConsoleOutput function just uses that handle to write to the file and log every line. This works great UNTILL...
I have a function AddConnection in the ConnectionManager class like this:
<pre>
void ConnectionManager::AddConnection(SOCKET _sd)
{
ClientConnection *cc = new ClientConnection;
cc->s = _sd;
cl.push_back(cc);
PrintClientList();
}
</pre>
This just adds the socket in a struct to the list, this is the PrintClientList() function:
<pre>
void ConnectionManager::PrintClientList()
{
cout << "Client list(by socket handle):" << endl;
CLI cli;
for ( cli = cl.begin(); cli != cl.end(); ++ cli )
{
cout << (*cli)->s << endl;
}
return;
}
</pre>
So whenever i add a connection it adds it to the list and prints the list of socket handles out to the console. This works fine untill logging is turned on. If i leave out the printing of the list (so PrintClientList()) then it works fine, but if i include it my app crashes, even though it prints it fine if logging is disabled.. I can't figure out what the problem is.. Does anyone have any ideas?
Kuniva
--------------------------------------------
|
|
|
|
|
Why toolbar created by following code do not creates tool-tips?
I checked that string resiurce is presented ith button identifier,
and property of promt if button is set to this string.
<br />
<br />
if (!m_wndToolBar.CreateEx(this,<br />
TBSTYLE_FLAT,<br />
WS_CHILD | WS_VISIBLE | CBRS_TOP<br />
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC <br />
)<br />
|| !m_wndToolBar.LoadToolBar(IDR_MAINFRAME/))<br />
<br />
<br />
thanks you
|
|
|
|
|
Hi,
Sorry for the very basic question - I am a beginner so please excuse me:
Could someone please tell me where I can find info on using a rich edit box in a dialog-based application without using any MFC? I mistakenly thought that it would be as simple as using any other control, but it seems not. All I want to do is have a white box with a lot of text in it and a scrollbar to scroll through it (user can't input anything). I guess a rich edit box is what I need. But I tried to add a rich edit box to my dialog and then set its text using SetDlgItemText, and if I compile and run, the dialog just exits without showing _anything_, as though the program hasn't run at all. It seems this has nothing to do with my code (well, it probably has something to do with what I'm _not_ doing in my code), as even if I took any code out relating to the rich edit box, so long as it was in my dialog, if I run, it exits as though nothing has happened. I read on MSDN that you need to call AfxInitRichEdit(), but when I tried this I just got an "undeclared identifier" message, so I guess this is just for MFC...
Any pointers would be really appreciated. Sorry again if this is a dumb question.
Many thanks,
KB
|
|
|
|
|
Have you loaded the riched32.dll (for RichEdit 1.0) or riched20.dll (for RichEdit 2.0) library? This is all that AfxInitRichEdit() does
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|