|
That's okay. In fact - I didn't make any call to the method of object 2. Please accept my apology for being unclear.
As I alluded to earlier, I can see two places where such a call would make sense.
In the first case, there would be action immediately after a radio button was pressed.
I imagine you would not have the same need to keep track of the currently selected option, so I've omitted that code from the following case statements.
Example 1: Immediate response
case IDC_RADIO1:
object2.handleSelectedRadioButton(1);
return true;
case IDC_RADIO2:
object2.handleSelectedRadioButton(2);
return true;
case IDC_RADIO3:
object2.handleSelectedRadioButton(3);
return true;
In this second example, you'll need to remember which radio-button is selected somewhere, before taking the appropriate action when the trigger is received (in this case, the pressing of the button labelled Test)
Example 2: Action taken in response to another input
case IDC_BTN_TEST:
if (curRadioOption == -1)
MessageBox(hwndDlg, "Select a radio button first!", "Error", MB_ICONERROR);
else
object2.handleSelectedRadioButton(curRadioOption);
return TRUE;
Something else I should mention, is that MFC will most likely allow the state of any control to be quickly and easily queried (not sure if there's an object used to represent a group of radio buttons - I'd imagine that there was) This will make my global variable curRadioOption redundant.
|
|
|
|
|
Pass a pointer to the object you want to notify in the constructor of the dialog, and have the dialog save that in a member variable.
Then when events occur, make a call to that object.
|
|
|
|
|
Hello
Thanks in advance.I have created different dialog for which are link by the main menu,but my problem is if i go from one dialog to another , how can i close it and save its contents
Waiting for reply soon
|
|
|
|
|
johnjitu wrote: ...if i go from one dialog to another , how can i close it and save its contents
The dialog is closed by clicking the Cancel button, the X, Esc, Alt+F4, or by calling EndDialog() . Where are you wanting to save its data to? Some internal data structure, or some external storage like a file?
"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
|
|
|
|
|
Thanks
I did not put any cancel or close,it is without title bar.I make sdi application with
full screen and in menu of upper level i put the chose where you can open the new
dialog.I am calling dialog boxes from the Viewclass.but didnot find how to close or switch to other dialog when user click the other options of open other dialogs
Do yo have any coding to calling mulitple dialogboxes in SDI applicaiton
Thanks
|
|
|
|
|
johnjitu wrote: Do yo have any coding to calling mulitple dialogboxes in SDI applicaiton
You need to first understand the difference between modal and modeless dialogs.
"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
|
|
|
|
|
hi
i looking to load the image in an window how can i do it i tried with CpictureHolder .does any alternative way to do it.
note am not looking to load on background
Reply as soon as possible .
thanks sarfaraz
|
|
|
|
|
Perhaps CImage[^] is what you need.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hello,
is there any c++ tutorial or (simple) open source sample how to write an OLE object that can be embedded into MS Office applications such as powerpoint?
Just like, for example, an Origin Graph or a corel draw image which are directly embedded into a powerpoint presentation.
When I search for OLE, I most often only find how to automate Office...
Alex
|
|
|
|
|
|
Thank you - this was easier than I expected.
Alex
|
|
|
|
|
I can insert my ActiveX object into Powerpoint and save/restore the data.
Now, I would like to automatically create a new object from a certain file type - ideally by drag and drop into Powerpoint. How can I achieve this?
Thank you in advance.
Alex
|
|
|
|
|
I never did that, however, I suppose you have to write a Shell Extension for that, check out the great article series[^] of Michael Dunn, here at CodeProject .
Veni, vidi, vici.
|
|
|
|
|
|
|
Please don't post the same question at multiple places.
The identical question in the Q&A section [^] already contains answers.
|
|
|
|
|
Alright, Fine, I got that. Now any answers?
|
|
|
|
|
Hi All,
I have a function in C++ dll like
FunctionCPP(int s)
{
}
I have a function in C# application(exe) like
int FunctionCSharp(int s)
{
return s;
}
what is the procedure to call FunctionCSharp from FunctionCPP?
Any help will be appriciated.
Thanks
G.Paulraj
|
|
|
|
|
Not sure how this would work with a C++ DLL loaded into a C# application, but read what MSDN[^] says here, maybe it can get you going.
Registering/Using somekind of inbetween COM interface sounds like a good idea.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
hi all
here is the my code[quick_sort),plz point the errors,remove the errors plz
i want run this programme in fedora also[what exactly the header file would be to find time consumed for sorting a given array[sorted/unsorted] ]
#inlcude<stdio.h>
#include<conio.h>
#include<time.h>
Const int MAX=1000;
Int partition(int a[],low,int high)
{
Int I,j,,temp,key;
Key=a[low];
I=low;
J=high+1;
While(i<=j&& key<=a[i]);
{
i++;
}
While(key>a[j]);
{
j--;
}
If(i<j)
{
temp=a[i],a[i]=a[j],a[j]=temp;
}
Else
{
Temp=a[low],a[low]=a[j],a[j]=a[low;
Return j;
}
}
Void quick_sort(int a[],int low,int high)
{
Int mid;
If(low<high)
{
mid=partition(a,low,high);
quick_sort(a,low,mid-1);
quick_sort(a,mid+1,high);
}
}
Void main()
{
Int a[MAX],n,I;
Clock_t end,start;
Start=clock();
Printf("enter the no of elements:");
Scanf("%d",&n);
Printf("\n enter the elements to sort\n");
for(i=0;i<=n:i++);
scanf("%d",&a[i]);
quick_sort(a,0,n-1);
end=clock();
printf("\n the sorted elemetns are:\n\n"(;
for(i=0;i<=n:i++);
printf("%d\t",a[i]);
printf("\n\n time consumed the array is: %5.2f sec",(end-start)/CLK_TCK);
getch();
}
|
|
|
|
|
One thing I noticed is that u are starting the clock before providing the input so if u take 5 minutes to enter the elements it will also be counted as time-took-to-sort. so better move the start & end as below:
<br />
<br />
Start=clock(); <- remove from here<br />
Printf("enter the no of elements:");<br />
Scanf("%d",&n);<br />
Printf("\n enter the elements to sort\n");<br />
for(i=0;i<=n:i++);<br />
scanf("%d",&a[i]);<br />
Start=clock(); -> put it here<br />
quick_sort(a,0,n-1);<br />
end=clock();
now the algorithm running time is not including the time for printing the messages and taking user input.
|
|
|
|
|
One more thing, i have not done the statistical analysis though but u are using 2 while loops one nested inside other why not simlify it with one while loop, Here is my implementation for the same, hopefully it will help:
<br />
void swap(int a[], int i, int j)<br />
{<br />
int temp = a[i];<br />
a[i] = a[j];<br />
a[j] = temp;<br />
}<br />
<br />
void qsort(int *arr, int first, int last)<br />
{ <br />
int pivot;<br />
int left = first;<br />
int right = last;<br />
<br />
assert(arr != 0);<br />
if(left >= right)<br />
{<br />
return;<br />
}<br />
pivot = left++;<br />
while(left <= right)<br />
{<br />
if(arr[left] < arr[pivot])<br />
{<br />
swap(arr, left, pivot);<br />
pivot = left;<br />
++left;<br />
}<br />
if(arr[right] > arr[pivot])<br />
{<br />
swap(arr, right, pivot);<br />
pivot = right;<br />
--right;<br />
}<br />
}<br />
<br />
qsort(arr, first, pivot - 1);<br />
qsort(arr, pivot + 1, last);<br />
}<br />
|
|
|
|
|
hi Rahul
thanks for the reply
but your programme[modified used 1 while] doesnt give the time consumed to sort the given array
right?
|
|
|
|
|
Well I will then suggest the use of Boost's time duration class. I think there is one because i used to sometime back. check out the documentation of boost.
|
|
|
|
|
Beside moving the start=clock() call to a more appropriate place as previously suggested, an old trick I learned in order to have reproducible test timings, always start your timing run on the beginning of a fresh clock tick.
clock_t start, end, tt;
tt = clock();
while ((start = clock()) == tt);
...begin timing test
end = clock();
Don't start the timing until you get a different answer from clock(), now you have a whole clock tick to work with.
|
|
|
|
|