|
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.
|
|
|
|
|
You should capture the return value from WaitForSingleObject to see why it did not wait. You also need to check that your worker thread is actually doing some work rather than returning immediately.
NOTE: Please enclose your code snippet in <pre></pre> tags (use the "code block" button) to make it more readable.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Wait on the thread handle, not on the pointer to the thread class.
|
|
|
|
|
Good point.
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]
|
|
|
|
|
I wonder why that compiles for him...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
>Nothing is free in the universe.<
|
|
|
|
|
it compiles 'cause Microsoft made a horrible decision with kernel handles in NT - they made them all void pointers so any type of pointer is compatible with them. You can pass any old rubbish pointer into most kernel functions where it expects a kernel handle and the compiler can't tell the difference.
Ironically this is unlike GDI handles which they'd already made specific structure pointers in Windows 3.1 - 3 years previously. Such is life... [1]
If you're prone to messing this sort of thing up a lot (as I am) then you can make things a bit more type safe in C++ by defining an overload of WaitForSingleObject:
DWORD WaitForSingleObject( CWinThread *thread_ptr, DWORD msec_to_wait )
{
return WaitForSingleObject( *thread_ptr, msec_to_wait );
}
which will catch this sort of error. It's a right pain in the bum to have to that though and you have to make sure that you include your API wrappers otherwise you're back to square one (and there's the old catch-22 - if you know enough to use the typesafe wrappers you know enough to not need to use them).
Cheers,
Ash
[1] I suppose the difference was that in Windows 3.1 if you got a handle wrong you had to reboot as you'd trashed the system, in NT you'd just mess up a process.
|
|
|
|
|
Damn, you are right, i should have thought of that...i must be getting old and senile...what are we talking about again?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
>Nothing is free in the universe.<
|
|
|
|
|
As already suggested, you have to check the return value of every API function you call, otherwise... troubles.
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]
|
|
|
|
|
OK, here is your problem: you are passing the returned value (CWinThread pointer) from AfxBeginThread to WaitForSingleObject, which is not correct. Instead, you should pass the HANDLE defined inside those m_pcThread1 and m_pcThread2. Like so:
WaitForSingleObject(m_pcThread1->m_hThread,INFINITE);
WaitForSingleObject(m_pcThread2->m_hThread,INFINITE);
--
Arman
|
|
|
|
|
Hello,
WaitForSingleObject takes a handle as first argument. You are passing a pointer to a CWinThread.
Changing your code to
WaitForSingleObject( m_pcThread1->m_hThread, INFINITE );
WaitForSingleObject( m_pcThread2->m_hThread, INFINITE );
should solve your issue.
Regards
Frank
|
|
|
|
|
Hi all
I have stranger problem in dialog box Control disappear from dialog.There is no issue of memory and cpu uses,both are normal.I want to know what reason behind this situation?
Please help me..
|
|
|
|
|
can you be more specific with the scenario?
|
|
|
|
|
Thanks for reply
[B]scenario[/B] I have a dialog A and modless dialog B.Modless Dialog B call on button click of Dialog A.I use timer to show Watch in Modless dialog B.When i set time for One hour then this thing is happen.
|
|
|
|
|
please tell that what is disappearing from where?
|
|
|
|
|
ok Button,Check Box,Static Box from Main Dialog A.
|
|
|
|
|
please be more precise, where do you set timer? or post code portions..
|
|
|
|
|
Set timer in main dialog A.
extern CStatic m_settime;
CdialogADlg* test;
m_dialogB= new CdialogB(test);
m_dialogB->Create(CdialogB::IDD,0);
m_dialogB->CenterWindow(test);
void CdialogADlg::OnTimer(UINT_PTR nIDEvent)
{
if(nIDEvent==1)
{
m_settime.SetWindowText("Time start.");
}
CDialog::OnTimer(nIDEvent);
}
|
|
|
|