|
See here[^].
You can use the code from the link, just need to replace the printf call with conditional check - if the process ID matches your own process ID, obtained via GetCurrentProcessId[^].
modified on Wednesday, January 5, 2011 6:13 AM
|
|
|
|
|
|
I have a SDI app using FormView that's not resizable but will have a large and small size. I would like to create small and large dialogs and then have the view display the correct dialog depending on user choice. I don't want to use multiple views because I don't want to recode handlers, etc. My plan is to i.e. have button ID_OK1 in small dialog and button ID_OK2 in large dialog both to to OnOK() so my code only has to be written once. Any ideas would be appreciated. Thanks,
John
|
|
|
|
|
If it is just about the size of the dialog, isn't resizing the child windows based on the user selection a simpler choice? I have seen articles on CP that show how to do that.
|
|
|
|
|
I was thinking about doing resizing but I have another app that allows resizing and it was a bit tedious to change control sizes, rearrange based on the new window size and update font sizes. I was hoping to layout 2 dialogs in the resource editor and then just switch between the two. Is there an easier way to resize controls instead of calc window size, scale controls then move to new relative positions?
|
|
|
|
|
TBH, I never had to do resizing seriously, so I can't say anything useful about that.
About your original issue, I just felt that resizing would be a lot less code, and bloat, than mapping events from both the forms to some base class, friend class etc and processing them.
|
|
|
|
|
I actually did find something useful. Adding this line to the CFormView constructor lets you use any dialog for the form view:
CMFCView::CMFCView()
: CFormView(CMFCsdi2View::IDD)
{
m_lpszTemplateName = MAKEINTRESOURCE(View_IDD_TO_USE);
}
So at run time I can set View_IDD_TO_USE to the resource for IDD_DIALOG1 or IDD_DIALOG2. The form view then gets created with whichever of the resources I choose. I create the event handlers in the view, i.e. OnOK(). The controls in each dialog need to be the same including names so that when the view creates the handlers they can be mapped, i.e. there must be a control named ID_OK on each dialog so the view can correctly map ID_OK to OnOK().
That means no duplicated code, only two dialogs which doesn't add to much overhead. This works great for what I'm doing.
Thanks to Scott McPhillips for the direction.
|
|
|
|
|
My problem: I need to give to icons resources identifiers values based on other (buttons) identifiers values.
example, if i have a button with CM_TEST identifier, i need to have a corresponding icon with a resource ID = CM_TEST+xxxx
I tried the method explained below without success
Including Shared (Read-Only) or Calculated Symbols
http://msdn.microsoft.com/en-us/library/zakskay9.aspx
my rc file contains:
#define APSTUDIO_READONLY_SYMBOLS
#include "dialogh2.h"
#undef APSTUDIO_READONLY_SYMBOLS
my dialogh2.h content some icons identifiers as:
#define IDI_OK (IDOK+20000)
#define IDI_OK_DISABLED (IDOK+30000)
#define IDI_CANCEL (IDCANCEL+20000)
#define IDI_CANCEL_DISABLED (IDCANCEL+30000)
Result: all identifiers are not calculated and seems to get a value of 0.
some observations:
-icon property window show :
ID: "(IDOK+20000)"
(quotes are present)
-when displaying rc resource symbol dialog, my identifiers IDI_OK, IDI_OK_DISABLED ... don't appear (read-only symbols checkbox checked)
-I did some tests as :
#define IDI_OK (1+20000)
same result..
In all cases, identifiers seems to evaluate to 0 (because they become my app icon and i already have an app icon with ID = 1)
How to solve this problem ?
Thank you very much in advance
|
|
|
|
|
The evaluation of resource symbols does not appear to work when those symbols are used as labels in the resource script as:
#define ID_X 100
#define ID_Y (ID_X + 10)
ID_X ICON ...
ID_Y ICON ...
I suspect there is some information in the link you posted, but the comments from Microsoft are not very clear.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Your example is exactly what i see.
Microsoft seems to say that this should work but .... how???
|
|
|
|
|
Pascal_33 wrote: Microsoft seems to say that this should work but .... how???
It doesn't! I have tried this a number of different ways and it just does not work. The problem is that in the .rc file the 'calculated' value is replaced by the preprocessor but the rc compiler does not recalculate it but accepts it as a string value.
#define IDI_X 100
#define IDI_Y (ID_X + 100)
...
IDI_X ICON ...
IDI_Y ICON ...
100 ICON ...
(ID_X + 100) ICON
which is obviously wrong. It seems that rc will not recalculate expressions that are used as labels in resource scripts.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Pardon the silly question: "did you include dialogh2.h in your dialog's source (*.cpp ) file?"
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
In your post you showed it included into the *.rc file (not inside the dialog *.cpp file).
I've made a test, it worked for me.
Nevermind, I did the wrong test.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Wednesday, January 5, 2011 9:04 AM
|
|
|
|
|
Sorry
Just try to include it in the cpp file and no changes. In your case, is it the fact to include read-only header file the cpp file that is successful?
(I'm really very interested on your tests since i already spent 2 days on this problem without result)
|
|
|
|
|
Sorry, my test was simply wrong.
I haven't yet found a way to make the new defined IDs appear in the Resource Window. However if you're not scared of manually editing the *.rc (with, for instance the notepad) file then you can make it work.
BTW: be careful, IDs > 32767 are reserved for MFC .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The problem is Visual Studio change ID when it want ...
I try to build many applications (total over 100,000 lines) originally developped with the old Borland c++ 5.0, with the help of OWLNEXT library.
These apps have dialog specific visual aspects (radio, checkboxes, buttons ...) and for example, for a given ID button you can assign icons images displayed inside the button: icon with ID= ButtonID+20000 give a button icon for the normal state, and icon with ID = ButtonID+30000 give a button icon for the disabled state.
This is the context of my work. With the old Borland C++ it was very easy to define resource ID depending on other resource ID.
|
|
|
|
|
If you are using MFC you could use a CBitmapButton MSDN[^]. CBitmapButton ties the image resources to the buttons caption instead of it's ID.
What I do when I have to do this kind of thing is use the readonly resource header, but put manually calculated values in it, it can be a pain to maintain but it works.
|
|
|
|
|
I don't want to use MFC (huge work to convert from OWL library).
I think i have to put manually, as you said, the calculated values in the read-only resource header
|
|
|
|
|
A workaround comes from the top of my mind. You may use your Symbol.h file as input for Pre-Build step, the latter consisting in the creation of the actual header included by the resource script.
However. I don't know if this is worthy the effort (for instance you can't use the preprocessor for this task, you have to build a micro-lexer + a micro-parser, personally I would use a tool like awk or a scripting language like Perl or Lua).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
This seems a bit complicated ...
Thanks anyway
|
|
|
|
|
Yes, unfortunately (if you had some exposure on such tools, however the task would be a bit easier).
The nasty thing is that Visual Studio doesn't produce the right result (at least the one expected by you and me after reading the documentation).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello,
I am developing an ISAPI extension WildCard and a filter, now i want to pass information from the extension to the filter for each request, and the only way that i have found was to
pass the data throw the response header, but when i added a custom header (Example: MYHEADER), and try to approach from the browser in the second request the browser freeze and say that there was a problem with the response.
*The ISAPI extension not changing anything in the request, only log info and add one header to the response (1 time its adding a SET-Cookie and the rest its adding a custom header).
I have set cookie header that works fine, and i know that i can't run the function HSE_REQ_SEND_RESPONSE_HEADER twice on the same request, so i add the custom header only when i don't use the set cookie.
code snippet
string dicstr = "X-My-Header-UserID: 12\r\n";
DWORD dwSize = strlen((char*)dicstr.c_str());
ecb->ServerSupportFunction(ecb, HSE_REQ_SEND_RESPONSE_HEADER, NULL, &dwSize, (unsigned long *)(char*)dicstr.c_str());
Any idea why its happen when i added a custom header?
Thanks in advance,
Neo.
|
|
|
|
|
CWinThread* m_pcThread1;
CWinThread* m_pcThread2;
int a1[100], a2[100],a3[200];
para* a;
int* a9;
para* b;
int* b9;
int* ptr = a3;
a = new para;
b = new para;
a->main_ptr = a1;
a->val = 1;
b->main_ptr = a2;
b->val = 0;
m_pcThread1 = AfxBeginThread(WorkerThreadProc,a,THREAD_PRIORITY_NORMAL,0,0,NULL);
m_pcThread2 = AfxBeginThread(WorkerThreadProc,b,THREAD_PRIORITY_NORMAL,0,0,NULL);
// MessageBox("Thread Started");
// if(WaitForSingleObject(m_pcThread1, INFINITE) == WAIT_OBJECT_0)
WaitForSingleObject(m_pcThread1,INFINITE);
WaitForSingleObject(m_pcThread2,INFINITE);
a9 = a->main_ptr; b9 = b->main_ptr;
for(int i = 0; i<100;i++)
{
*ptr = *a9;
*(ptr+100) = *b9;
ptr++;
a9++;
b9++;
}
MessageBox("Calculated");
------------------------------------------------------------
Above code is not waiting for thread to complete. I can not understand
what is the problem? please help me
|
|
|
|
|
And what does your thread function look like?
It was ever thus, the Neophiles will always rush out and get 'The Latest Thing' at a high price and with all the inherent faults - Dalek Dave.
|
|
|
|