|
Rama Krishna wrote:
In that case derive a class from CDllCache
Thanks for the tip Actually, I thought of doing something like that, but I hoped there was a simpler solution.
Thanks again.
I vote pro drink
|
|
|
|
|
What's about the following idea:
Do you really need DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications in your DLLMain?
If not, you could disable them at loadtime (during DLL_PROCESS_ATTACH) by calling DisableThreadLibraryCalls(). Then at DLL_PROCESS_DETACH time you could simply signal your thread and wait until it has ended. Because it does not have to go through DLLMain any more, no deadlock should arise.
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
As I said in my original post, I have tried that already, but it just doesn't work: the bloody thread just won't end while any other thread is in DllMain even if DLL_THREAD_DETACH notification is disabled.
I vote pro drink
|
|
|
|
|
Nemanja Trifunovic wrote:
As I said in my original post, I have tried that already, but it just doesn't work: the bloody thread just won't end while any other thread is in DllMain even if DLL_THREAD_DETACH notification is disabled.
Ehm, you said this in your original post???
However, it is really sad that it does not work. Seems that the system uses internally a process wide Mutex/CS that has to be passed during ExitThread - regardeless if the tread afterwards calls DLLMain or not
I frequently get the feeling that this "only one thread in DLLMain at a time" thing brings us more headaches than it solves. Better teach developers to deal gracefully with concurrency and let them do the things on their own!
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
I was trying to populate a richedit ctrl and had a callback function etc, When I tried to run it - "failed to create empty document". and a blank frame shows up. So I undid I believe everything and got the same error. I am going to scrap this copy but am terribly puzzled as to why and how to recover.
Ideas and suggestions are welcome!\Thanks,
ns
|
|
|
|
|
You need to call AfxInitRichEdit() if you are using RichEdit 1.0.
Chris Richardson
|
|
|
|
|
Where do I call this function? In OnInitialUpdate of my view class in which the control resides?
Thank you so much!!!
ns
|
|
|
|
|
That did it. I put it in the apps initinstance....
I reallly appreciate your help!!!
Many thanks,
ns
|
|
|
|
|
No problem ... sorry for the semi-vague reply the first time.
Chris Richardson
|
|
|
|
|
Dear Friends,
I want to develop a notepad type application using
doc/view architecture.If you got the code please mail at
kashif1112000@hotmail.com
|
|
|
|
|
CEditView or CRichEditView will be helpful in such application. It will save you a lot of coding.
|
|
|
|
|
Jeff Prosise's "Programming Windows with MFC" has an excellent example located within chapter 12, you might want to check it out.
-Ken Mazaika
|
|
|
|
|
I read something about mb_autoDelete but cant find it now . At one point I destroy a view, and I think I'm suposed to safeguard the document by setting this variable to something (True or FAlse). Is mb_autodelete a member function of the doc class? I didnt see it in the doc.h file. MSDN has no relevant info. what should I set it to and WHERE should I set it?
Thanks for helping,
ns
|
|
|
|
|
To be honest with you, your question is a little vague, however, I think I've found the answer you're looking for.
An auto delete member variable is a fairly common thing and could be anywhere. However, I do believe what you are looking for is m_bAutoDelete and not mb_autoDelete. It would help to learn the notation used by Microsoft. In this case m_ means member variable and b means boolean. So the correct variable name is m_bAutoDelete. If you do a search in the MSDN library with your Visual Studio install for this variable name, you'll see that the variable you are looking for is in fact in the CDocument as you suspected.
This particular member variable tells MFC not to delete the document when the view is destroyed if you set it to FALSE.
Here's some code from the MSDN library used in a replace view method:
CDocument* pDoc = pView->GetDocument();
BOOL bSaveAutoDelete = pDoc->m_bAutoDelete;
pDoc->m_bAutoDelete = FALSE;
pFrame->SetActiveView(NULL);
Good luck.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Thanks. But my program started acting very flakily when I added this snippet. SO I am going ahead with the DestroyWindow without regard to m_bAutoDelete. It really makes my app behave weirdly. I'm glad I tried it though---
Thanks,
ns
|
|
|
|
|
I'm just getting started with VC++. I want to be able to loop through several Control IDs without referencing each one individually. As an example:
for (... each dialog control id ...) {
::EnableWindow(::GetDlgItem(*this,id),true);
}
Other than assigning an array of pointers to each Dialog Control ID, I don't know of a way to cycle through them. Is it possible?
I realize that the control IDs are simply defined integer values, but can i assume that the Class Wizard will define them in sequential order?
Thanks for any help you can provide.
Todd Krzeminski
tkrzeminski@nlxcorp.com
|
|
|
|
|
here's a way to enable/disable all child windows in a dialog:
BOOL CALLBACK EnumEnableChildWndProc( HWND hwnd,
LPARAM lParam);
BOOL EnableChildWindows(HWND hWndParent, BOOL bEnable)
{
return EnumChildWindows(hWndParent, EnumEnableChildWndProc,(bEnable ? 1 : 0));
}
BOOL CALLBACK EnumEnableChildWndProc( HWND hwnd, LPARAM lParam)
{
::EnableWindow(hwnd, (lParam ? TRUE : FALSE));
return TRUE;
}
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Sorry for not clarifying...My problem isn't that i necessarily wanted to enable/disable the controls.
I also need to get button states, manipulate text, stuff the results into shared memory segments, etc. I wanted a method to easily do this instead of having 20-some different references to 20-some controls; just one loop that handles them all. Since there aren't arrays of control ids, how can I do this?
I hope i'm explaining this correctly. But thanks for your help.
|
|
|
|
|
The above example is still correct, but perhaps you'd like something like:
<br />
UINT id[] = { IDC_CONTROL1, IDC_CONTROL2, IDC_CONTROL3, 0 };<br />
<br />
<br />
for (int i = 0; id[ i ]; i++)<br />
{<br />
CWnd *item = GetDlgItem( id[ i ] );<br />
item->EnableWindow( FALSE );<br />
<br />
}<br />
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
I see its like for a simple multi edit
m_string= "T line 1Text line 1\r\n";<br />
m_string += "Text line line 1Text lineText line 1 Text line line 1Text lineText line 1w\r\n";<br />
m_string += "Text line 1Text l 2\r\n";<br />
m_string += "Text line 4\r\n";
THen these entries are separate lines, and horizontal scrollbar shows up when necessary.
What I have is a bunch of text thats like a couple of paragraphs and I want to have it look normal in th editbox. I thought of using a richedit but dont know how to populate it. MSDN is talking about a StreamIn function but it looks awfully complicated. The text I have is coming in as a char* pointer.
Any hints?
Thanks,
ns
|
|
|
|
|
I'm going to try (from CP)
Couple of Questions: OnReadIn() is not a function in response to a message right? I didnt see anything like that in the classwizard.
This std_call function. Do I need to include it in the h file?
Thanks,
ns
|
|
|
|
|
In my dialog window, I have inset a child dialog using this code in the main dialog's OnInitDialog(). Since SubclassDlgItem() can't be used with a CDialog, I have used this code to place it in the location of the CStatic item IDC_SINSET:
<br />
m_pFrameViewWnd = new CFrameViewDlg(this);<br />
m_pFrameViewWnd->Create(CFrameViewDlg::IDD,this);<br />
<br />
GetDlgItem(IDC_SINSET)->GetWindowRect(r);<br />
ScreenToClient(r);<br />
m_pFrameViewWnd->MoveWindow(r.left,r.top,r.Width(),r.Height());<br />
m_pFrameViewWnd->ShowWindow(SW_SHOW);<br />
GetDlgItem(IDC_SINSET)->ShowWindow(SW_HIDE);<br />
There are more than forty various buttons and controls in the main dialog and the CStatic IDC_SINSET has a tab order of 12. However, no matter what the tab order of that static item is, the controls in the subdialog always seem to start only after all other controls in the main dialog. How can I make the controls in the subdialog have a tab order which is inserted at the same point in order as the static item to which the subdialog is assigned?
|
|
|
|
|
1.Add your child dialog in the tab order, in your OnInitDialog , add a call to ModifyStyle(0, WS_TABSTOP); .
2.If you want to pass control to the next available control in the tab order of the main dialog, you need to extract that information from your child object (IDC_SINSET)
and set focus on it when the last control. You will need to overwrite PreTranslateMessage and call NextDlgCtrl of the main dialog.
|
|
|
|
|
I want to click on a (3rd party) picture box which has an image with a particular index in it. I want to pass this index into the Buttondownhandler for the picture box which has this signature:
void CTrain1View::OnLButtonDownThbimage3(long Keys, long x, long y) <br />
{<br />
<br />
}<br />
How would I do that?
Thanks
|
|
|
|
|
First of all, you probably don't want to mess with the OnLButtonDown signature. I don't think that is the best approach. As far as I know there is no way to do what you are asking. Button handlers are implemented with callbacks using macros. There is no way that I can see to tell the macro to pass a variable to the button handler. Someone correct me if I'm wrong.
Since you're talking about a third party product, it's difficult to tell you the best way to do this without knowing the API for that product. If, for instance, your picture box handles it's own events (click, mouse over, etc.), the index for the current picture is probably being updated automagically. Just find a member function in your picture control ( GetIndex or something like that ), that tells you what the current picture index is. If, however, you have to handle the events on your own, it could be any number of possibilities. I don't think there's an easy answer for you in that case.
Here's a few questions you need to answer:
1. Where is the index for each picture getting stored?
2. Is the value of the current index being updated automatically by the control or is that something I have to do myself?
3. If the control does handle the updating of the index value, do I have a way to access the control member variable from my button handler?
4. Is there a member variable ( m_cPictureControl or something like that ) representation of the control? If not, use class wizard to create one.
That's the best I can offer. Good luck.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|