|
|
Looks Great Mark,
What's it supposed to do?
Bram van Kampen
|
|
|
|
|
Maybe you didn't read the post...
It does everything I want it to do...that changes several times a day.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
She sure is Sexxy
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
Hello,
I have a class which i created, it calculates some mathematical functions, Can i use or create "_beginthread" in the class?
i tried to do it, but i got this error:
error C2664: '_beginthread' : cannot convert parameter 1 from 'void (void *)' to 'void (__cdecl *)(void *)'
class CMaClasse<br />
{<br />
public:<br />
void FoncAppnt(void* args);<br />
void FoncApp(void* arg);<br />
};<br />
<br />
void CMaClasse::FoncAppnt(void* args)<br />
{<br />
_beginthread(FoncApp,0,(void*)a); <br />
}<br />
<br />
<br />
void CMaClasse::FoncApp(void* arg)<br />
{<br />
}
-- modified at 18:18 Friday 9th November, 2007
|
|
|
|
|
Gofur Halmurat wrote: Can i use or create "_beginthread" in the class?
Sure. But, if your thread proc is a class method, that method needs to be static...
class CMaClasse<br />
{<br />
public:<br />
void FoncAppnt(void* args);<br />
static void FoncApp(void* arg);<br />
};<br />
<br />
void CMaClasse::FoncAppnt(void* args)<br />
{<br />
_beginthread(& CMaClasse::
FoncApp,0,(void*)a); <br />
}<br />
<br />
<br />
void CMaClasse::FoncApp(void* arg)<br />
{<br />
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Can I use public variable in static function?
because i have some public variables in the class
|
|
|
|
|
A static method can only access static class members.
To get around this, typically a pointer to an object of the class is passed
to the thread proc. Then the thread proc can use that pointer to access
non static members of the class.
Here's an example (my changes are in red)...
class CMaClasse
{
<font color="Red">void *pThreadArgs;</font>
public:
void FoncAppnt(void* args);
static void FoncApp(void* arg);
};
void CMaClasse::FoncAppnt(void* args)
{
<font color="Red">pThreadArgs = args;</font>
_beginthread(&CMaClasse::FoncApp,0,<font color="Red">this</font>);
}
void CMaClasse::FoncApp(void* arg)
{
<font color="Red">
CMaClasse *pThis = (CMaClasse *)arg;
pThis->pThreadArgs->...</font>
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thanks Mark,
It helped me alot!!!
|
|
|
|
|
|
Just to explain this behavior see: http://www.parashift.com/c++-faq-lite/pointers-to-members.html.
Briefly, the type of pointer-to-member-function is different from pointer-to-function .There is not cast (new in VC++2005).
|
|
|
|
|
george.dumitru wrote: There is not cast (new in VC++2005).
I never heard of "not cast"!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
There is no cast to non-member function pointer.
|
|
|
|
|
Hi All,
I'm sure that someone has had this problem before. I only wanted to reorganize the constants a little bit when I decided to compile again and boom! ... the famous RC2135 while compiling resources. I installed SP1 but it's still there. I can't compile my project anymore.
I really appreciate any help.
Thanks.
rotter
|
|
|
|
|
I have an input box that a user can enter in 4 characters like 1.34. I need to check if there is a decimal in the input string and truncate everything after the tenth place. Is there a C/C++ function that I can use for this? Thanks
|
|
|
|
|
will CString :: Find help you?
|
|
|
|
|
Using "Add memmer variable wizard", add a variable (Category=value) and set ‘Max chars’ to n.
Or, DDV_MaxChars(pDX, yourVar, 10);
-- modified at 3:50 Saturday 10th November, 2007
|
|
|
|
|
george.dumitru wrote: sing "Add memmer variable wizard", add a variable (Category=value) and set ‘Max chars’ to n.
How does that find the "decimal in the input string and truncate everything after the tenth place"???
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
kani98 wrote: I need to check if there is a decimal in the input string...Is there a C/C++ function that I can use for this?
Check out strchr() , or string::find(), or CString::Find() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Is there a C/C++ funciton that will remove a character from a string? I want to remove the decimal from the input string. If someone enter 1.23, I want to use only 1.2, remove the decimal making it 12.
|
|
|
|
|
I am trying to use the MS sample in my code and and cannot get it to add an other nodes other than the first node .
<br />
<br />
CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE1);<br />
ASSERT(pCtrl != NULL);<br />
<br />
<br />
TVINSERTSTRUCT tvInsert;<br />
tvInsert.hParent = NULL;<br />
tvInsert.hInsertAfter = NULL;<br />
tvInsert.item.mask = TVIF_TEXT;<br />
tvInsert.item.pszText = _T("United States");<br />
<br />
HTREEITEM hCountry = pCtrl->InsertItem(&tvInsert);<br />
<br />
<br />
HTREEITEM hPA = pCtrl->InsertItem(TVIF_TEXT,<br />
_T("Pennsylvania"), 0, 0, 0, 0, 0, hCountry, NULL);<br />
<br />
<br />
HTREEITEM hWA = pCtrl->InsertItem(_T("Washington"),<br />
0, 0, hCountry, hPA);<br />
<br />
<br />
pCtrl->InsertItem(_T("Pittsburgh"), hPA, TVI_SORT);<br />
pCtrl->InsertItem(_T("Harrisburg"), hPA, TVI_SORT);<br />
pCtrl->InsertItem(_T("Altoona"), hPA, TVI_SORT);<br />
<br />
pCtrl->InsertItem(_T("Seattle"), hWA, TVI_SORT);<br />
pCtrl->InsertItem(_T("Kalaloch"), hWA, TVI_SORT);<br />
pCtrl->InsertItem(_T("Yakima"), hWA, TVI_SORT);
Anything missing here ?
|
|
|
|
|
Are you getting good HTREEITEM values returned from the InsertItem() calls?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
yes
Engineering is the effort !
|
|
|
|
|
Your code worked for me.
Try double clicking on United States.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
ohh i was assuming that the defaul style was to expand all cells.
I think i need to set the style to expand all cells
Thanks for your help and sorry for the inconvenience .
Engineering is the effort !
|
|
|
|