|
Hi,
Is it possible for a thread to suspend itself?? If yes, can you please give me a simple example??
What I know is:
(Class)*ptr;
...
ptr->SuspendThread();
But, can it be suspending itself??
Thank you!!;)
|
|
|
|
|
Just call SuspendThread from inside the thread code (I'm assuming you're using MFC worker threads, aren't you.) Of course, it has to be another thread that brings this one to life again with ResumeThread .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes,.. I am using MFC worker threads.
Great! Thanks!!![Big Grin | :-D](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_biggrin.gif)
|
|
|
|
|
Hi there,
Can somebody please help me????.
I have a list box and a text box in my application, i need to know how to load the value of the string in the list box, to the text box with the puSh of a button.
|
|
|
|
|
Add this code to the function that handles the event when the button is pushed.
- Send a LB_GETTEXTLEN message specifying the index of the listbox that you want the text for, This will tell you how much memory you need to allocate for the string.
- Allocate a buffer that is large enough to hold the string.
- Send a LB_GETTEXT message to the listbox specifying the same index.
- Call SetWindowText on the edit control in order to set the string into the edit control.
- Delete the memory that you allocated for the string.
If you are using MFC, you can use the correpsonding member functions to the messages that I told you about in the CEdit and CListBox classes to do the same thing.
Refer to msdn.mircosoft.com for more details.
|
|
|
|
|
so would i do this?
//m_lsFile is the CList control variable to the listbox
//m_sFile is the CString control to the textbox
int nIndex;
CString str;
m_lsFile.GetTextLen(nIndex);
m_lsFile.GetText(nIndex, str);
m_sFiles.SetWindowText(str);
str.Delete(nIndex);
If you could let me know that would be great.
Thanks again.
|
|
|
|
|
Thats right, except since you are using MFC and CStrings, you do not need to get the text length because the CString hides the memory allocation for you. You also do not need to delete the CString for the same reason.
CString str;
m_lsFile.GetText(nIndex, str);
m_sFiles.SetWindowText(str);
|
|
|
|
|
ok now this will sound real stupid but, i am bewildered here. i am the perfect picture of a newbie at c++, in an mfc project i want to hide and show controls, any button i place on a edit box, or listview are not visible... even if i place them on the dialog and move them, in vb we could right click and "Bring to Front", is there nothing close to that, or do i have to size and place the controls as i show them... thanks in advance
shotgun
|
|
|
|
|
I'm not sure what exactly you're after, but try 'Tab Order' command from 'Layout' menu.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
I beleive he is talking about ZOrdering of controls, and if there is any way to change this from the dialog editor.
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
It's obvious you're coming from VB camp, David
In Win32 API, z-order *is* 'tab order'.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Tomasz Sowinski wrote:
It's obvious you're coming from VB camp, David
And proud of it
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Absolutely.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
There the same thing...?
I thought zOrder was vertical or depth of the control.
Like layers or divs in DHTML...a high zOrder makes the layer a top level window.
Tab order was basically the order in which the controls were created?
Their is no difference...?
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Tab order determines the order in which controls are created. Created controls are inserted sequentially into child windows list of their parent. Order on this list is z-order.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
You may want to try the beginner tutorials for VC++. I've tried that and it helps ALOT. Try the Button Control....... (I am new too..)
|
|
|
|
|
You can experiment with the Transparent checkbox in the controls properties (Extended Styles tab)... not sure if thats what you want, but I think its the closest thing to 'Bring to Front'...
|
|
|
|
|
I have a split view which is declared like:
CMainFrame *pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
pFrame->m_wndSplitter.ReplaceView(0,0,RUNTIME_CLASS(CMyFormView),CSize(500,320));
pFrame->m_wndSplitter.ReplaceView(1,0,RUNTIME_CLASS(CMyFormView2),CSize(500,500));
In one of the formview's i have a list control, and a combo box which need to be populated. When I try to overload either OnInitialUpdate(), or OnActivateFrame() they never get called (im assuming because of the split window)..
So what function should be overloaded to populate my combobox and list? Any Suggestions?
thanks for the help!
-dz
|
|
|
|
|
What's 'ReplaceView'? Anyway, you may want to call CFrameWnd::InitialUpdateFrame to get OnInitialUpdate called.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Hi there,
I don't want start a big war between VC++ 6.0 and VC++ .NET
But i have question of VC++ programmers about it !
Question:
WHAT IS YOUR REASON FOR USING VC++ .NET ?
DO YOU WANT TO CHANGE TO VC++ .NET ?
hmmm, let me open the problem:
WHEN I MUST USE VC++ .NET ?!!!
Please tell me your idea
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
no point in studying something that will be outdated soon.. thats why i ordered .net.. although the loss of classwizard has still left a bad taste in my mouth
-dz
|
|
|
|
|
I'll be moving over to VC++.NET IDE when I have finished my current projects. The reasons to move. Well, mainly because VC6 won't be getting updated. Some of the new ATL Server stuff looks like it might be useful. New MSDN will only integrate into the new IDE.
I'm not 100% convinced about the new IDE yet but I know I'm going to have to learn it sooner or later.
I won't be developing many apps for the .NET framework in C++ as my customers aren't asking for it yet.
If you are still developing C++ apps for Windows then there is no rush to move over to .NET IDE.
Michael ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Using VC6 SP5 ...
I'm trying to hook the CFileDialog with the following :
...
CFileDialog dlg(FALSE);
CHAR fileBuf[256] = { "output.ext"};
dlg.m_ofn.nMaxFile = 256;
dlg.m_ofn.lpstrFile = fileBuf;
dlg.m_ofn.lpstrDefExt = "ext";
dlg.m_ofn.Flags = OFN_EXPLORER|OFN_ENABLEHOOK;
dlg.m_ofn.lpfnHook = (LPOFNHOOKPROC)OFNHookProc;
...
and I'm getting an ASSERT in DLGFILE.cpp (mfc sources )
...
if (nResult)
ASSERT(pThreadState->m_pAlternateWndInit == NULL);
...
The Callback is
UINT_PTR CALLBACK OFNHookProc(HWND hdlg,
UINT uiMsg,
WPARAM wParam,
LPARAM lParam
)
{
if ( uiMsg == WM_NOTIFY )
{
NMHDR *phdr = (NMHDR *)lParam;
switch (phdr->code)
{
case CDN_FILEOK:
{
TCHAR filename[255];
DWORD dwResult = SendMessage( (HWND) GetParent(hdlg),
CDM_GETSPEC,
(WPARAM) 255,
(LPARAM) filename );
std::wstring s(filename);
if ( !ValidateFileName(s) )
{
AfxMessageBox(L"Invalid file name");
::SetWindowLong( hdlg, DWL_MSGRESULT, 1 );
return 1;
}
}
}
}
return 0;
}
Anything that I missed ? seems that all the flag are ok?
The question is that when I type "<" in the filename text field, I don't get the WM_NOTIFY in the callback, and Windows pops a standard dialog saying that what I typed is invalid, but when I type ">" I do get the WM_NOTIFY and goes into my code ??! and both caracters are invalide filename caracters?!!? Any clue on that ?
Thanks for any info.
Max.
|
|
|
|
|
Can't you just override CFileDialog::OnFileNameOK? MFC does hooking for you - you don't need to play low-level.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Gawd, I feel like a dork !!! Arrggggg!
Sorry!
Max.
|
|
|
|