|
ok...when you press a button show a modeless dialog with a edit control to show text.
Class view:
void Cprueba4View::OnButton2()
{
CEjemplo *dlgDesc;
dlgDesc = new CEjemplo();
dlgDesc->Create( IDD_DIALOG1 ,GetDesktopWindow());
dlgDesc->ShowWindow(1);
}
In class CEjemplo:
void CEjemplo::ShowText(void)
{
CString cadena= _T("Hi, it is a example");
m_Edit.SetWindowTextW(cadena);
}
But I need, to show text from other class in the same dialog, that mean, the text, it will be added in the same windows when I press other button.
Every button are in the ribbon.
|
|
|
|
|
antonio343 wrote: I need, to show text from other class in the same dialog
How about making the ShowText function as public and pass a CString variable ;
void CEjemplo::ShowText(CString strText)
{
m_Edit.SetWindowTextW(strText);
UpdateData(FALSE);
}
call the public function of CEjemplo object as,
void CSomeOtherClass::ShowText()
{
CEjemplo oEjemplo;
CSting strText(_T("Some text from other class"));
oEjemplo.ShowText(strText);
}
|
|
|
|
|
ok, but..
Where I define strText?
And.. to show the text I need the method OnInitDialog in class CEjemplo, but if I add the parameter I need to pass the paramenter to this method and it isn't possible.
BOOL CEjemplo::OnInitDialog()
{
CDialogEx::OnInitDialog();
ShowText();
return TRUE;
}
|
|
|
|
|
So add a function to your dialog that manages the text, then you can call that function as different buttons are pressed. However, I would say that your design is not the best way of doing things in Windows.
|
|
|
|
|
I didnt understand you.
If you know a better way to do, let me know, please.
|
|
|
|
|
As I understand it you are changing the content of the dialog by pressing a button on the main form. This will not be a good experience for your users, as most people like to interact with one window at a time.
For example:
If the user presses a button on the main form and a dialog appears, all user action should now be with that dialog until the dialog is dismissed. If they have to go back to the main form to press a button to change something in the dialog then things get confused.
If my understanding of your system is incorrect I apologise for my confusion.
|
|
|
|
|
The idea is it dialog is used to show dates. The app will be a estadistic program, like SPSS, you will have a several variables and if you choose one of this and press a one button, in the dialog will be show the average, and if you after press other button, it will be added to the dialog the frecuency, for example.
Due to it, I'd like to get show diferent information from diferent class in the same dialog.
Please, help me.
|
|
|
|
|
Your original message states that this is an MDI application, so it would seem the obvious answer is to show your results in one of the MDI windows. Alternatively put all your selector buttons into the dialog and just use the button handlers to get the data from wherever it is held and display it in the dialog.
|
|
|
|
|
No, I cant.
This windows/dialog is only to show the result.
Now, I show each result in one dialog diferent, but I'd like to group all the result in one dialog, and after, I will make a button in this dialog to save the information in a txt for example.
But I must to do at this way
|
|
|
|
|
antonio343 wrote: No, I cant.
I have offered two suggestion which would make life easier for you, I cannot think of a third that would be better.
|
|
|
|
|
You never clarified whether you were using a modal or modeless dialog. I don't think your issue can be addressed until that is made clear.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I'm sorry, you are right. It is a modeless dialog.
I'm triying use set and get DlgItemText, but maybe I dont know how to use it.
I made this:
void Cprueba4View::OnButton3()
{
CString cadena;
GetDlgItemText(IDC_EDIT1, cadena);
cadena += "Helloo other time ";
SetDlgItemText(IDC_EDIT1, cadena);
}
|
|
|
|
|
Do not interact with UI controls from any place other than the owning window (the modeless dialog in this case). If you need the modeless dialog to update its controls, send it a message.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Ok, finally, I got my answer.
I solved of this way:
I made a public variable of my dialog class, where is the edit control, in the class view, and I made the windows in the builder. After, when I press a button, I did :
void Cprueba4View::OnButton3()
{
CString cadena;
dlgDesc->GetDlgItemText(IDC_EDIT1, cadena);
cadena += "Hello other time ";
dlgDesc->SetDlgItemText(IDC_EDIT1, cadena);
dlgDesc->SetFocus();
}
But now, I have another problem. When I maximize the windows dialog, only it's maximized the windows and not the edit control. why? how can I maximize the windows and the edit control at the same time?
I used
dlgDesc->ShowWindow(SW_MAXIMIZE);
to maximized
|
|
|
|
|
antonio343 wrote: how can I maximize the windows and the edit control at the same time?
Why can't you use SetWindowPos() on the edit control? It's a window too.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I tried this, but it can't run.
I did this:
BOOL CEjemplo::OnInitDialog()
{
CDialogEx::OnInitDialog();
m_Edit.SetMargins(10,10);
m_Edit.ShowWindow(SW_MAXIMIZE);
return TRUE;
}
is it right? If not.. how I use showWindow()?
|
|
|
|
|
antonio343 wrote: I tried this, but it can't run.
Which means what?
antonio343 wrote: m_Edit.SetMargins(10,10);
Are you thinking that setting a control's margins will also affect it's physical dimensions?
antonio343 wrote: m_Edit.ShowWindow(SW_MAXIMIZE);
Unless the control's width and height have been changed (see SetWindowPos() ), it is already maximized.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
m_Edit.SetMargins(10,10); is so that the text don't appear next to the border.
Ok, I will try with SetWindowPos.
I will tell you my progress
modified 3-Oct-11 18:20pm.
|
|
|
|
|
I dont know how to use this function. Please, teach me.
|
|
|
|
|
How to count positive values WHILE doing HeapSort? Here is my HeapSort and I count them in a loop at the end of the method, but it needs to be done while sorting. How's that?
void Sift(int arr[], int left, int right)
{
int i, j, x;
i = left;
j = 2 * i + 1;
x = arr[i];
while (j <= right)
{
if(j < right)
if(arr[j] < arr[j + 1]) j++;
if (x >= arr[j]) break;
arr[i] = arr[j];
i = j;
j = 2 * i + 1;
}
arr[i] = x;
}
void HeapSort(int arr[], int n)
{
int left, right, temp;
left = n / 2 + 1;
right = n - 1;
while (0 < left)
{
left--;
Sift(arr, left, right);
}
while (0 < right)
{
temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
right--;
Sift(arr, left, right);
}
for(int i = 0; i < n; i++)
if(0 < arr[i]) PosCount++;
}
|
|
|
|
|
This question was already posted in Q&A[^]; please post in one location only.
0100000101101110011001000111001011101001
|
|
|
|
|
|
Have you tried placing the counting code within either of those other loops to see if it counts what you expect? At first glance, I'd try:
while (0 < right)
{
temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
if (0 < arr[right])
PosCount++;
right--;
Sift(arr, left, right);
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
modified 13-Oct-11 9:39am.
|
|
|
|
|
Yes, the problem is that I don't understand the HeapSort good enough to reshape it whatever I want. That's why i need help..
|
|
|
|
|
Code aside, what part of the heap sort do you need help with: building the heap, or adding to the sorted array? I would forgo coding until I could do it all on paper first.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|