|
viperlogic wrote: Does "delete pThread" call ExitThread??
No. At the point in which you are deleting pThread , the thread has already terminated. You are just cleaning up the CWinThread object.
ExitThread() is called from within the secondary thread, unlike TerminateThread() which is called from outside the secondary thread.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
i think i have that working now.
A kind of related problem i have is with the code below. This is a part of the code the thread executes, if sucessful all is ok. this thread has a timeout of 3secs. A problem is that the ConnectServer call below takes 2minutes to complete if it cant connect. when this happens the below messagebox pops ups and then the program crashes. is it crashing because the code wants to "return" but there is nothing to return to as the thread has been already killed?? How can i modify it so that it wont crash. A message box doesnt have to be displayed either.
many thanks
<br />
hres = pLoc_test->ConnectServer(<br />
_bstr_t(L"\\\\"+strIP1+"\\root\\cimv2"),
NULL,
NULL,
0,
WBEM_FLAG_CONNECT_USE_MAX_WAIT,
0,
0,
&pSvc_test
);<br />
<br />
<br />
if (FAILED(hres))<br />
{<br />
char error_msg[64];<br />
sprintf(error_msg, "wmi_test: Could not connect. Error code = 0x%x", hres);<br />
MessageBox(error_msg , "Error" , MB_ICONERROR | MB_OK);<br />
<br />
pLoc_test->Release(); <br />
return; <br />
}<br />
|
|
|
|
|
Since you are using WBEM_FLAG_CONNECT_USE_MAX_WAIT , why not set your WaitForSingleObject() call to also wait for 2 minutes (or a little more)?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
i am scanning alot of hosts with this app, waiting 2mins for every host would take for ever to scan the network, hence i use the thread timeout of 3secs
i just read about _endthread and it appears to work so far. is this a proper solution?
|
|
|
|
|
viperlogic wrote: i am scanning alot of hosts with this app, waiting 2mins for every host would take for ever to scan the network, hence i use the thread timeout of 3secs
I did something very similar to this in a ping-type application. For each machine that I was going to ping, I just created a secondary thread and put the ping-related code in it. Given that the machines each responded in their own time, the threads all completed at different times; some were instantaneous while others took a lot longer. If your UI has some sort of listbox or list control for these machines, give them a default status of "Establishing connection. Please wait...". When that machine's thread terminates, replace the default status with what actually happened.
viperlogic wrote: i just read about _endthread and it appears to work so far. is this a proper solution?
Not unless you also used _beginthread() . Regardless, it is called from within the secondary thread. Terminating a thread from within itself is vastly different than terminating a thread from some other thread.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I am implementing a Drag and Drop operation on a TreeView. I've supplied a bitmap to my tree and it draws wonderfully.
Now, when the user begins dragging - I call TreeView_CreateDragImage ... and for the most part, it works except that the dragging image (a folder) overlaps the textual part of the drag so that when you are draggin and move the mouse around, you can't see the first few characters of the TreeView node's text in the dragging image.
I can't see how to affect this. Are my bitmaps too large? I initially supplied a bitmap strip 128x16 and told the TreeView the images were 16x16. I've move the hotspot around in TreeView_BeginDrag ... For the most part, CreateDragImage is a black box - it just creates the draggable image. I've no idea how to affect the placement of the text relative to the image.
Any suggestions would be appreciated. Thanks in advance,
-Luther
|
|
|
|
|
I need to fill in numbers with all possible configurations of defined string length:
say choose string length N=5
and get all combinations from 00000 ... 99999
and so for any chosen N for the code to be universal
give some code please
9ine
|
|
|
|
|
9ine wrote: and get all combinations from 00000 ... 99999
Can you not just use a for /while loop?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I need to go to sleep...
yes I see looping thru 00000 ... 99999 is equal to scrolling thru all combinations
9ine
|
|
|
|
|
you have the maximum number for the combination like that :
long lMax = 0;
CString str = ;
for (int i = 1; i < str.GetLength(); i++) {
lMax += 9 * ::pow(10, i);
}
then, you iterator from 0 to lMax...
|
|
|
|
|
Sorry sorry I have awaken and realized ...
I need to code the parsing of:
given the number of dimensions N
say N=6
and given the maximum number of single dimension size
say a,b,c,d,e,f a=300,b=100,c=400,....
to parse thru all possible combinations of them
from 0,0,0,0,0,0
1,0,0,0,0,0
2,0,0,0,0,0
...
...
a,b,c,d,e,f
the total number of combinations will be a*b*c*d*e*f
9ine
|
|
|
|
|
if anyone can suggest better code?
m_dsize[] = {a,b,c,d, .... }
pos[] = {0,0,0,0, ... }
//pos will be filled with all possible configurations
while(true)
{
//increment counter
for(int i=0; i<dim; i++)
="" {
="" pos[i]++;=""
="" if(pos[i]="">=m_dsize[i])
pos[i]=0.0f;
else
break;
}
float sum=0.0f;
for(int i=0; i
|
|
|
|
|
9ine wrote: if(!sum) break;
Why are you using a logical NOT operator with a float ?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I thought it was not forbidden. why not float value stored as 32 bit number and if it is 0.0 then its 32 bit equivalent 0x00000000
9ine
|
|
|
|
|
9ine wrote: I thought it was not forbidden.
Just because something is syntactically correct does not also mean it is good practice.
9ine wrote: why not float value stored as 32 bit number and if it is 0.0...
Using the equality operator with float (or double ) is a really bad idea.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi,
Does anyone know how I can remove the highlight selection in the listview control. I just want to be able to have the user to select the checkboxes.
Thanks.
|
|
|
|
|
Use the SetItem() method to turn off the LVIS_SELECTED state.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
You can use the following method to modify the state
for removing of selection where
state = 0
nMask = LVS_SELECTED
SetItemState( int nItem, UINT nState, UINT nMask );
Knock out "T" from CAN'T
You 'CAN' if you think you 'CAN'
-- modified at 0:36 Wednesday 5th April, 2006
|
|
|
|
|
Hi,
I've done a dialogbased project and created databases(MSACCESS) using recordset(class wizard).Now my problem is where do u declare this m_pSet?
In SDI u do it in VIEW Class,but in dialogbased where do u do it?
I get the foll errors when I execute the program:
m_pSet :Undeclared identifier
pls help me
swapna_signsin
|
|
|
|
|
i think you are trying to reuse some code you saw somewhere on the web.
i don't know what type is m_pSet , but refering to its name, ,i think it could be a CRecordSet*
and as there is a prepending m_ it means that it is a member of a class.
but tell me where you found your source ??
|
|
|
|
|
hi,
well thats right,it was the method I used in SDI application in which m_pSet gets automatically.It is a recordset.
Actually Iam a beginner to databases and I just wanna connect my database(MSACCESS) with two fields name and grade thru dialogbased.
How do u think I should proceed?
bye
swapna_signsin
|
|
|
|
|
swapna_signsin wrote: In SDI u do it in VIEW Class,but in dialogbased where do u do it?
Make it a member of the dialog class.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi,
I am using a slide control in a dialog and I used Visual studio to create it and place the slider on it.
When I want to add the tick marks, I have a problem. I must use the Create function for that with the "TBS_AUTOTICKS" flag, but the problem is that I can't use the Create function since Visual Studio already did it for me using the macros.
Any way to set this flag or override the Create function macro ?
Shay
|
|
|
|
|
Just check the "Auto ticks" checkbox in the resource editor.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Why couldn't I think about it before
BTW, I am using VS 2003 and it also need the Tick Marks property checked.
Thanks !
|
|
|
|