|
Hi, everyone!
In my main function, I allocate a Tls index and creates
a father thread, and the father thread creates a child
thread. I want to know whether I can safely use the Tls index
in the child thread?
The following are the sample codes.
Thanks in advance,
George
DWORD dwTlsIndex;
DWORD WINAPI ChildFunction(VOID)
{
//can we use Tls by dwTlsIndex here?
return 0;
}
DWORD WINAPI ThreadFunc(VOID)
{
//use Tls by dwTlsIndex;
//create another child thread from this thread
//suppose the thread function of the child thread is
//ChildFunction
return 0;
}
DWORD main(VOID)
{
DWORD IDThread;
HANDLE hThread;
int i;
dwTlsIndex = TlsAlloc();
hThread = CreateThread(NULL, // no security attributes
0, // use default stack size
(LPTHREAD_START_ROUTINE) ThreadFunc, // thread function
NULL, // no thread function argument
0, // use default creation flags
&IDThread); // returns thread identifier
WaitForSingleObject(hThread, INFINITE);
TlsFree(dwTlsIndex);
return 0;
}
|
|
|
|
|
A TLS index is available for all your threads (giving them all "personal" storage of a 32-bit entity - imagine this with Win64 ;-> ).
It's no longer a question; reading documentation is a virtue of the past.
|
|
|
|
|
I have a check box and 2 edit boxes in 'read only' attribute in a dialog based application. I want that when i should click checkbox the attribute of these edit boxes should change to 'write' attribute and vice versa
Hoping for a positive response...
|
|
|
|
|
MFC solution :
Get a control to the checkbox named m_MyCB, and one on each edit box, say m_Edit1 and m_Edit2.
Go in the ressource editor, double click on your check box, and in the created function (which should be something like (CMyDialog::OnCheckBox()):
BOOL b=m_MYCB.GetCheck()
m_Edit1.SetReadOnly(!b);
m_Edit2.SetReadOnly(!b);
If you're doing it in Win32 without MFC, write back.
Hope this was not a homework or Christian will crush me
~RaGE();
|
|
|
|
|
Hi all,
I want the selected text from the site I am working on..lets suppose i am working on google and i am searching something and i select a phrase or something from there and then I want this text for some work in my application..any help and any pointers are highly appreciated..thanks in advance..
Himanshu
|
|
|
|
|
document.selection.createRange().text will give you the selected text.
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks mike. But ca you please give me some piece of code where you are using it..I think it is not working for me..what is document here I mean it is an object of what..
hope you can help..thanks for the time..
waiting...
Himanshu
|
|
|
|
|
|
:(thanks neville,
but can you help!!! do you know bit of code which gets the selected text from web page and can display in edit box of a dialog..also if you can tell me how to get the url rom address bar of ie.
thanks a lot..
Himanshu
|
|
|
|
|
There are certain occasions that our release builds crashes on our clients computers. As such a dialog box is displayed by operating system showing something like " The instruction at 0x1111 referenced memory at 0x0001, the memory could not be read"
Friends, what i want is that whenever program crash happens, this dialog box is not displayed. Instead my own dialog box appears in which i can get the crash information and my client simply email that information to me. How can i achieve this goal of getting crash information and preventing OS dialog?? Any sample example code??? I've seen many commercial MFC applications in which whenever such crash occurs, their own dialog box is displayed and i simply click a button to send this information to them.
|
|
|
|
|
a very high-level try{ } catch(...) block will catch many of these things. but, it's still better to prevent them from happening in the first place.
-c
ILockBytes
|
|
|
|
|
Chris Losinger wrote:
a very high-level try{ } catch(...) block will catch many of these things
If he wants to catch SEGV errors he has two choices. SEH or SetUnhandledExceptionFiler. No need to confuse him with C++ and C++ exceptions implemented-in-terms-of-SEH-but-still-not-catchable.
If you use SetUnhandledExceptionFiler, take note that the debugger will swollow this when debugging. But since you get tese SEGV's from running client installation I guess debugging isn't of importance, right?
|
|
|
|
|
|
I'm looking for a source code snippet for calculating the inverse hyperbolic sine of a number. I.e. an implementation of "double __cdecl asin(double);". It's not a member of <math.h>. Can anyone help?
|
|
|
|
|
found this on Google:
asinh(X) = Log(X + Sqr(X * X + 1))
acosh(X) = Log(X + Sqr(X * X - 1))
atanh(X) = Log((1 + X) / (1 - X)) / 2
-c
ILockBytes
|
|
|
|
|
|
hi,
I want to set the mouse cursor to "Hand" when it moves over a button ,placed in a dialog.I did'nt find any mouseover message for button in the class wizard.Can any one help me..please..
Mahesh
|
|
|
|
|
There is no OnMouseOver function in MFC like the wellknown one used in another language . Basically, you'll have to create it yourself. Let's go.
Create a class derived from CButton , for example CMyButton (use the class wizard).
Get a control asociated to your button( use again the class wizard - Add Value, do not forget to switch the combo to "Control"), f.e. m_MyButton.
Change the line CButton m_MyButton to CMyButton m_MyButton .
Now, right click on CMyButton in your class browser, and chose Windows Messages. DoubleClick on WM_SETCURSOR so as to create the OnSetCursor function.Then, in CMyButton::OnSetCursor([some stuff i can't rememeber]) , load your new cursor, and comment out the line where the base class function is called (i.e. do not return what is originally returned), otherwise your own cursor won'T appear.
To sum up, what you did is :
Create your own CButton derived class named CMyButton .
Create a control, replace the original CButton using your class CMyButton .
In this class, handle the WM_SETCURSOR message with the overriding CMyButton::OnSetCursor() function.
DO not forget to comment the last line out.
Hope this helps.
~RaGE();
|
|
|
|
|
Thanks Rage...Thanks a lot..
|
|
|
|
|
Hi :
I have a question on OnSetCursor for CRectTracker. During tracking, it shows the resize arrows when the mouse pointer is at the edges. Such as <->.
How do I overwrite this if I want it to display another icon, maybe a different color hand ?
The CRectTracker->OnSetCursor function returns only a BOOL, so I suppose the cursor is not set there.
Any pointers will be appreciated.
|
|
|
|
|
Quek Khoo Boon wrote:
The CRectTracker->OnSetCursor function returns only a BOOL, so I suppose the cursor is not set there.
It is. Override this function, comment out last line, and set your own cursor in it.
~RaGE();
|
|
|
|
|
Hi
A beginner here.We always use GetDocument() function of CView class to retrieve a pointer to the CDocument class. However this time, i need to get the pointer from a CObject derived class. But i've no idea how to do that at all. Can anyone help?
Anyway i always wondered whether i should always place my data in the CDocument class. Because OOD seems to dictate that data should be contained in its own relevant classes for encapsulation. However the Document-View architect seem to suggest placing all data in the CDocument class. Any comments to help me resolve this paradox?
thks
moo
|
|
|
|
|
raner wrote:
Any comments to help me resolve this paradox?
there's no paradox. the "document" in doc-view is the data. the doc itself can contain other classes to actually hold the data (like arrays or whatnot), but the CDocument class is (theoretically) supposed to be the embodiment of your data. the view is just a way to look at the data.
raner wrote:
i need to get the pointer from a CObject derived class
the easiest way is to just carry around a pointer to your CDocument. but, you can also get a pointer to the current doc via CFrameWnd::GetActiveDocument (and you can get the frame wnd from CWinApp).
-c
Zzzzz...
|
|
|
|
|
but my class is CObject derived, so how do i make use of CFrameWnd::GetActiveDocument to import the pointer? thks thks
To carry around the pointer, do you mean something like the below codes?
In CView class:
CPgmDoc* pDoc= (CPgmDoc*) GetDocument();
CMyObject *pMyObject= new CMyObject;
pMyObject->SetDocument(pDoc);
In CMyObject:
void CMyObject::SetDocument(CRainAttDoc *pDocument)
{
pDocument=pDoc;
}
thks for the help.Sorry if this seems painfully elementary;P
|
|
|
|
|
yeah something like that. (carrying it around).
raner wrote:
so how do i make use of CFrameWnd::GetActiveDocument to import the pointer?
something like this:
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
CDocument *pDoc = pChild->GetActiveDocument();
this only gets the "active" document, so it might not do exactly what you want.
ILockBytes
|
|
|
|