|
Get clean build seems to do more than clist thanks
|
|
|
|
|
I cannot create MyListBox derived from CFormView. The docs say I can put the Create call in the MyListBox ctor.
I get these errors:
// dialog template must exist and be invisible with WS_CHILD set
// invalid dialog template name
I don't want to create a resource dialog template, however, like an IDD_... because my listbox is just a PLACE_HOLDER control in a resource control.
How do I get the object created without a dialog resource IDD?
|
|
|
|
|
What does the relevant code look like?
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi,
I am following an example from a book, and I have an WaitForSingleObject that works just first time and I don't know
how to resolve that.
The main things are happening in the ChildThreadProc. At the first execution of the ChildThreadProc the procedure steps through all lines of code, but when is launched again, the execution stops at WaitForSingleObject, as if hAutoEvent isn't signaled or I don't know what is happening, and please help me to figure this out.
So,
In the WindProc main procedure when the window is created, is created the Event also:
case WM_CREATE: hAutoEvent = CreateEvent ( NULL, FALSE, TRUE, "EXAMPLE-AUTOEVENT" );
return DefWindowProc(hWnd, message, wParam, lParam);
The example of WaitForSingleObject is presented in the following procedure:
DWORD WINAPI ChildThreadProc ( HWND hWnd )
{
char szBuffer[256]; HANDLE hAutoEvent = OpenEvent( SYNCHRONIZE, FALSE, "EXAMPLE-AUTOEVENT");
wsprintf(szBuffer, "Thread %x waiting for Event %x", GetCurrentThreadId(), hAutoEvent );
SendMessage(hWnd, WM_USER, 0, (LPARAM)szBuffer);
WaitForSingleObject(hAutoEvent, INFINITE );
wsprintf(szBuffer, " Thread %x got event", GetCurrentThreadId() );
SendMessage(hWnd, WM_USER, 0, (LPARAM)szBuffer );
Sleep(2000);
wsprintf(szBuffer, "Thread %x is dome with event", GetCurrentThreadId() );
SendMessage(hWnd, WM_USER, 0, (LPARAM)szBuffer);
SetEvent(hAutoEvent);
CloseHandle( hAutoEvent);
ExitThread( TRUE );
The ChildThreadProc is started here:
case IDM_TEST:
{
DWORD id=0;
CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)ChildThreadProc, hWnd, 0, &id );
}
break;
and here is where text out is handled:
case WM_USER:
{
TCHAR szBuffer[101];
static int row = 0;
static int msg_num = 1;
HDC hDC = GetDC(hWnd);
FillMemory(szBuffer, 100, 32 );
TextOut( hDC, 0, row, szBuffer, 100 );
wsprintf(szBuffer, "%3d: %s", msg_num++, (LPSTR)lParam );
TextOut(hDC, 0, row, szBuffer, lstrlen(szBuffer) );
row = (row > 200 ) ? 0 : row += 20;
ReleaseDC(hWnd,hDC);
}
break;
Please help me to find what I am not doing right.
Thank you,
|
|
|
|
|
coco243 wrote: execution stops at WaitForSingleObject, as if hAutoEvent isn't signaled or I don't know what is happening
coco243 wrote: Please help me to find what I am not doing right. It's not signaled on the second pass. You are using an Auto-Reset event object. So when your ChildThreadProc thread exits the event goes back into a nonsignaled state. The operating system is managing this for you.
Event Objects (Synchronization) - Win32 apps | Microsoft Docs[^]
You could change to a manual signal and set/reset it yourself.
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you, I had made the event with manual reset and I had understood what it was to be understanded.
In additon, the main significant thing that I had catched it, it was that when the thread was exiting, even if I was signaled the event before exiting from thread:
SetEvent(hAutoEvent);
, the system automaticaly was unsigning the event.
Very tricky for me, I woldn't figured out by myself neither in 100 year, so,
Thank you very much,
|
|
|
|
|
coco243 wrote: I woldn't figured out by myself neither in 100 year You are doing an amazing job. I would be completely lost if I were forced to read Romanian documentation. I checked and unfortunately the MSDN isn't available in your native tongue. Event Objects (Romanian)[^]
|
|
|
|
|
Thank you,
With a little English, with a little will, maybe something came out.
Thank you again for your help,
|
|
|
|
|
Hi
is there a way to have one DrawItem Function if you have both a derived CStatic and CComboBox a function pointer to the drawitem function.
The Function itself takes into consideration both a static and combbox.
Not sure because the complier looks to see if you decalred a Drawitem for either a static or combobox
|
|
|
|
|
There is quite a difference between the two classes so it would not be easy. You could provide a DrawItem method for each which then calls out to a helper function to do the actual work.
|
|
|
|
|
That’s is not a bad idea Richard this may not be conventional but I think I’ll make the code part of DLL I have and pass the drawitemstruct
|
|
|
|
|
I have done vaguely similar things in the past, although not with these specific controls. And it should work the same whether it is part of the application or the DLL. The only requirement should be (I hope) that the code can distinguish if necessary between the two controls.
|
|
|
|
|
The ctltype will help yo distinguish thanks
|
|
|
|
|
I have a Clist however the type is defined as a structure
My question is I would like to match up against a member in the structure is this possible ? there maybe more that one occurence
Thanks
|
|
|
|
|
It's not clear what you're trying to do.
Define "match up against a member in the structure".
Maybe share a code sample.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Consider the following structure
struct stdecs
{
struct vsmdesc stordesc;
char *tcb = " ";
struct blkdesc blkdescx;
CList<blkdesc, blkdesc> freeblock;
CList<blkdesc, blkdesc> allocblock;
};
with the following Clist definition
CList<stdecs, stdecs> storagediscriptor;
Could I match for an equal against member tcb ? or any other member of the type stdesc
thanks
|
|
|
|
|
Sure, how about:
stdecs anotherinstance;
if (storagediscriptor[4].tcb == anotherinstance.tcb)...
if (storagediscriptor[5].stordesc == anotherinstance.stordesc)...
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I would have to loop
unitl storagediscriptor.GetNext == NULL
inspecting the member which is not too bad
thanks
|
|
|
|
|
You're welcome!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I figured push_back is for adding things at the front but if you want things added at the tail you should probably use insert. I`m having trouble calling insert, I don`t know how to fill in the parameters. Could someone lend a helping hand?
Quote: void AddTask(vector<task *=""> * UnitTasks, int type )
{
Task * T = new Task();
T->Type = type;
int nSize = UnitTasks->empty() ? -1 : static_cast<int>(UnitTasks->size());
UnitTasks->insert(T,nSize);//?
}
modified 26-Apr-22 1:54am.
|
|
|
|
|
Actually, as its name suggestes, push_back adds an item at the back of the vector.
Try the following sample code in order to see insert in action:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector <int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
cout << "v-front " << v.front() << "\n";
cout << "v-back " << v.back() << "\n";
v.insert(v.begin(), 4);
cout << "v-front " << v.front() << "\n";
v.insert(v.end() - 1, 5);
v.insert(v.end(), 6);
for (auto x : v) cout << x << " ";
cout << "\n";
}
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Thanks CPallini
the reason for which the ide wouldn`t accept my insert function was because I switched the order of parameters in the function, the intellisense function helper description is impossible to understand.
modified 26-Apr-22 9:09am.
|
|
|
|
|
You are welcome.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Hi,
Just wanted to point out that you should choose the right STL container. The vector is designed for sequential insertion/access. If you want to frequently insert at both ends then you should consider using a std::deque
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks for your tip, at this point I`m still not sure what I want to use.
|
|
|
|