|
Hello
I have problems with adding a property page in a new thread. The problem is CPropertyPage::AddPage() always produces debug assertion failure, when running from a thread.
it looks like this:
UINT SomeThread(LPVOID p)
{
...
CMyPropertyPage* newpage;
newpage=new CMyPropertyPage;
pdlg->m_PropertySheet.AddPage(newpage); //debug asertion failed
...
}
pdlg in this example was restored from the FromHandle function. I know that this error is caused by the fact that AddPage() is run in separate thread. Anyone knows how to do it properly ?
I will appreciate any suggestions... thanks
|
|
|
|
|
Post a message to the original thread to add the page. (PostThreadMessage)
Good Luck,
Bill
|
|
|
|
|
Thanks for the reply...
..but the thread in which CPropertySheet was created is the main user interface thread... and I don't know how to send it a ThreadMessage...
Is there any other solution ?
|
|
|
|
|
Ok,
Problem : Cannot get window handle to CPropertySheet
Solution : No problem, all we need is the thread handle and
we can post a msg to it.
Analysis : Ok, every MFC project contains the global CWinApp derived object.
Use that to get the handle of the main thread, and do a PostThreadMessage.
MFC takes care of the routing, so dont worry.
Just make sure that the id of the msg is unique and
there is a handle in the CProp(Page)(Sheet) you want to handle
the message.
|
|
|
|
|
hi all,
there is something not very important, but annoying :
* how can i include images into a project ? i know it's possible to do so within the ressource editor but only for .GIF, .ICO and what about .JPG ?
thanx
|
|
|
|
|
Just Import it into the resources, with a custom resource type string, like "JPG".
-c
The ants are my friends. They're blowing in the wind.
|
|
|
|
|
I have MDI type app.. with in CMainFrm I have a worker thread that needs to access one of the views to update the data.. The thread works fine as long as I dont pass it a pointer to the view.. how can I access the view from with in the thread? This is how I am trying to access the view..
CListView* pList = (CListView*)(MDIGetActive()->GetActiveView());
This view will allways be the active view when the thread is started.
Any ideas?
Rob
|
|
|
|
|
It may be better to have the main thread access the view. Have the worker thread post a message to the mainthread (PostThreadMessage).
Good Luck,
Bill
|
|
|
|
|
When you use the window in the worker thread,
they will not execute since windows depend on the
message loop to dispatch mesgs.
And obviously your worker thread does not have a mesg loop.
So the next best solution is to have a function in the
view and have the worker thread post a mesg which will
be handled and acted upon by the main ui thread with
the PostThreadMessage.
Use a user defined message which will map to the said fn.
|
|
|
|
|
Hey folks..
I have a dialog based application who's background is a DARK_CYAN color. I have two TabControls on this dialog, each of which need to have a different background brush.
When I call:
SetClassLong ( hwndFirstTab, GCL_HBRBACKGROUND, (LONG) hDarkCyanBrush );
It sets the background of both tab-controls to be DarkCyan, and understandably so, "class" = controls of type in Win32.
Anyone have any tips that would give me what I want, without getting my hands into CustomDrawing?
I've looked at SetWindowLong() for an option to change the background brush, but no luck.
Thanks!
Mike
doner@obtain.com
|
|
|
|
|
Mike Doner wrote:
Anyone have any tips that would give me what I want, without getting my hands into CustomDrawing?
Sorry, but i think drawing it yourself is going to be the way you have to go. Shouldn't be too hard i think, handling WM_ERASEBKGND should do it.
If you need something fancier, there are two nice articles on owner drawn tabs here on CP.
---Shog5---
From now on we can call C# and MC++ "The square wheel languages" -- Jack Handy, The Lounge
|
|
|
|
|
I've converted my source code to work with the new Standard C++ library headers. i.e. iostream, fstream, etc. But, I can't seem to open files in binary mode for read/write cuz my data is all screwed up. The documentation says setmode() no longer can be used for the new iostream library.
I'm using...
open(fileSpecPassed, ios::in | ios::out | ios::binary);
Does the iostream library not work with files in a binary mode?
|
|
|
|
|
Well, the new iostream s library supports the binary mode. I've done it in the past, so your problem is hopefully solvable Could you post a little code showing how you use the library?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I keep running into the same ol' crap again. I'm converting some code that works in Borland C++ 5.01 to VC++ 6.0. Anyways, code that worked in Borland obviously doesn't in MSVC. You were right, it does work in binary. It turns out that the sizeof operator does not work the same between versions so I was off in reading contents of objects.
Previous programmer had statements like:
stream.Read(&site.peArray, sizeof(site.peArray));
where peArray was defined as:
#define MAX_PE_PER_SITE 4
TPerEcho peArray[MAX_PE_PER_SITE];
The object is 6 bytes long, a float + a short but it kept coming up with 8 bytes from the sizeof() operator (actually 32 instead of 24).
|
|
|
|
|
sizeof always works the same, it's the way the compiler packs structures in memory that changes. see "pragma pack".
-c
The ants are my friends. They're blowing in the wind.
|
|
|
|
|
Like Chris suggested, use pragma directive.
Never give-up on code, it will come back to hunt you some day.
Well not always if it ain't broke, but just never know...
Good luck!
"One good thing about getting older, you don't loose the ages you've been!"
|
|
|
|
|
BTW, how did you put it in binary mode? The way I did doesn't seem to work since when I did a Quickview on the parameters passed, it equaled 0x23 instead of 0x83 where 0x80 equals ios::binary and ios::in = 0x01, and ios::out = 0x02. The 0x20 value in the first set came from ios::nocreate which when added up equals 0x23.
I gave up and went to the old library but would like to know if it works in the Standard C++ iostream library.
|
|
|
|
|
In a HTML Dialog box pressing F5 refreshes the page. How do I disable it?
|
|
|
|
|
Hi,
I think that sinking the event 'OnBeforeNavigate2' and returning
a value of false for the 'Cancel' param should stop it.
[I am speaking in reference to the MFC wrapper class, but u should
be able to map to what ever programming u r using]
|
|
|
|
|
I have a class handling a dialog that stores user input using DoDataExchange(pDX). The user's data is to be accessible to a few other classes. I know I have to instantiate the dialog class to bring the object w/ its data into existence. If, however, I do that, I'll end up with the constructor's data (as oppose to user-defined data). How may I make dialog data accessible to the entire program? Thx.
ralf.riedel@usm.edu
|
|
|
|
|
Ok,
the design that the data is common to many classes and
still only resides in the dialog class ...???
Well I think that u can see whats' wrong here ..??
The design is wrong, IF you want the data to be accessible to all
classes you should put the data as a seperate entity and then
you should use that to instantiate the data(or simply a pointer to the
data in the dialog will be enough)
Although there may(will) be technical work arounds to this prob,
I think that a change in design will eliminate any other problems
you might encounter in future.
|
|
|
|
|
I suppose one way is to make the input variables static (and public) members of your dialog class. This will allow you to access them from other places using the CMyDialog::m_myStaticMember notation. However, I recommend you spend some time to think about where these variables really belong and how they will be accessed.
Regards,
Alvaro
Insanity: doing the same thing over and over again and expecting different results. - Albert Einstein
|
|
|
|
|
Hi, my name is Rui, i'm using VC++ 6.0 with WXP!
I ahve a form with lots of objects, and i need to acess each object0s member variable in a dinamic way. In VB it was quite easy to create an array in order to control a number of objects, but in VC++, i don't know how to do that!
Can you help me?
Thank you for your time!
|
|
|
|
|
You'll have to do it manually. Class Wizard won't help you there
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Hi,
You cannot do this using the class wizard.
But what you can do is something like this.
Assume that you have 10 edit boxes and you would like to
access them thru a string, then
declare in the header like this
CStringArray m_strEdit[10] ;
Now in the Dialog's DoDataExchange, you could write code like this,
DDX_Text(pDX, IDC_EDIT1, m_strEdit[0]);
DDX_Text(pDX, IDC_EDIT2, m_strEdit[1]);
DDX_Text(pDX, IDC_EDIT3, m_strEdit[2]);
..
..
Just a bit copy & paste and your r ready, by the way there
are many things in VC++ that u cannot do in VB(comparitively more more..)
|
|
|
|