|
Unfortunately, I mixed two solutions together and blundered. You shouldn't use PostThreadMessage, but rather call the PostMessage of the dialog from the thread. (i.e. mythis->PostMessage(WM_USER + 0x10....)
The value for your user message can be anything, just make sure it's unique (I've made that mistake before.)
You then need to make a custom handler for the Dialog for that specific user message. To make the dialog flexible, in the past I've passed and IDS_ define as the WPARAM (or LPARAM) and then the message handler simply loads that string and updates the edit control. (If you know that only the thread will be setting m_result, then you can get away without a critical section, but that may come back to haunt you someday.)
Here's a link to help explain that.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_MFCNOTES_TN006.asp[^]
|
|
|
|
|
hei, it works
Thks for the help, really appreciate it!!
regards,
afender
|
|
|
|
|
Hello All,
I have a question. Right now when I create a modeless dialog window, it appears over the parent dialog window. This is fine, but when I click on the parent dialog window, it does not appear over the child window. Let me set this up a little better.
I am using Visual C++ 6.0
I have a Dialog window called EntryWindow
I have a Dialog Window called ResultWindow
EntryWindow creates ResultWindow when you click on a button (called calculate)
So ResultWindow opens fine, but when I click on EntryWindow again, it STAYS underneath ResultWindow. How do I make it so that Either Dialog window I click on shows up on top?
Please help me out with this, I'd love to learn hwo to do this.
Thanks,
NickOne
|
|
|
|
|
Post the code you are using to do this so we can see if we can spot any problems.
Dave
|
|
|
|
|
Hi,
It's probably not possible, but, i'm trying to declare a static member function of a class with "C" linkage.
Why? cos i'm trying to have a fortran function call this member function of a class, and the first arg is a pointer to the class.
I know I can make this just a global function rather than a member function, but that doesn't seem right to me.
Here's what I've tried (which doesn't work)
extern "C" static void __stdcall DC_MOVE (CGraphView*& pGraphView, float *x, float *y);
I need extern "C" to get the compiler to decorate the names in a way that fortran can understand. __stdcall is the calling convention that fortran uses.
Any ideas? or can someone confirm that this is not possible?
Thanks
Jon
#include <beer.h>
|
|
|
|
|
You will probably need to define the function in a DEF file for the function name to be mangled in the way that you want. Or is it that your program isn't building properly?
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
I think you will have to remove all of the name decorations for the entire class, I dont think that you can do that for just one function inside of the class.
So you will need to do something like this:
extern "C" CGraphView
{
public:
...
static void __stdcall DC_MOVE (CGraphView*& pGraphView, float *x, float *y);
};
The only problem with this is that you will not be able to use function overloading in your class. So if that is a problem, then you may want to make it a global function.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I will try that; i'm not going to be using function overloading (this is a fairly lightweight class).
Only thing I worry about is that class CGraphView is derived from CView and implements dynamic creation. Which is a lot of hidden code that might break it.
#include <beer.h>
|
|
|
|
|
Hiya I am just wondering if anyone has come across this problem.
I have an SQL database which I read and write to. I write a number of items( Number, Planet Name )the first time to the database fine. The items go in fine and in order into their columns:
e.g 1. Jupitar 2. Venus 3. Mars 4. Earth
Then when I modify the table in some way, e.g like deleting all the items, and refill the table with the exact same code, they come out in a different order e.g
3. Mars 1. Jupitar 4. Earth 2. Venus
And I definitely have not changed the code and they are all definitely deleted. WEIRD!! I have tried the same in ACCESS and works fine every time, only wrong in SQL.
Does anyone have any ideas on this??
grahamoj.
|
|
|
|
|
It's not wrong at all. When you select records, they are returned in an arbitrary order unless you explicitly request a different order.
instead of "select * from mytable", try "select * from mytable order by [number]"
that will get you consistant results every time.
Jon
#include <beer.h>
|
|
|
|
|
|
Handling WM_CTLCOLOR should do it. If not, try WN_ERASEBKGND.
|
|
|
|
|
I've tried it with WM_CTLCOLOR but unsuccessful. Now I will try with WN_ERASEBKGND, thanks )
|
|
|
|
|
Hi,
I'm new to Carchive and Serialization so i will try to be as detailed as possible with my question.
I currently have a dialog box with a CListCtrl and what i want to do is serialize the CListCtrl. From what i have read , serialization will allow you to recreate your object/class based on storing member variables. I find code where they do this for one variable at a time i.e.
archive << m_bMyVariable;
etc...
i don;t know about you but i do not find this useful at all... i could write all this code myself...
what is special about the serialize() function?
what does IMPLEMENT_SERIAL do?
what i'm trying to do is take a "snapshot" of my list control with all its items, the currently selected item, the currently checked items etc... and save it to file so i can reload that state when i show the dialog box again.
now I could do this all manually but i thought i had seen something useful in serialization.
am i braking up the wrong tree?
thank you in advance,
|
|
|
|
|
If I click on my item in the CListCTrl, I cycle back to the red line THREE times (just from one click). I thought one click means the itemchnaged function runs ONCE...?
void CSearchView::OnItemchangedListctrlkeys(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if (pNMListView->uOldState == 0 && pNMListView->uNewState == 0)
return;
<code> m_optionsListBox.DeleteAllItems();</code> this breakpoint is stepped into THREE times and after the third time the UI shows up. Why three times and not just once?
Appreciate your help,
ns
|
|
|
|
|
Check the flags that get passed in the message. The old item gets unselected (one message) and the item you click on gets selected (second message). Not sure where the third one comes from, but check the state flags and it should be apparent.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
Hi! I'm a sig virus. Attach me to the end of your sig to help me take over the world!
|
|
|
|
|
The sequence goes something like this.
Selected
Repaint
Update due to repaint
Kuphryn
|
|
|
|
|
Ah - Thanks!!! Now I have to figure out how to set a flag which depends on stuff happening, and it gets set the first time around, but the subsequent two times it gets unset....
Like initially (firtst pass),, if my map is empty, so I say m_flag = TRUE, else false. Then it goes and fills the map. So obviously second time it passes through it sees that the maps filled and then of course the flag gets unset ad leads to chaos.....but at leat sI can see why now and can try to work around it.....
Appreciate your help,
ns
|
|
|
|
|
Ok, I know I am supposed to use ON_UPDATE_COMMAND_UI handlers for each menu item, but is there a way to do it for allof them from one function? I have a ton of these to go through if that is the case!
(I just want to enable-disable them)
Thanks
|
|
|
|
|
Yeah, just hook all the IDs up to the same function (i.e., when ClassWizard supplies you with a function name, just change it to be like OnUpdateAllMenuItems, and do this for every menu item you want to enable/disable at the same time).
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
Thank you. I got it all working!
Now I have a new problem.. When some of the top-level menues are disabled, then re-enabled some time later, they are not correnctly redrawn. They have the white from being diabled, and they aren't updated until the mouse is moved over them.
How can I get the whole top-level menu redrawn? (File, Edit, etc.)
Thanks again!
|
|
|
|
|
Call the DrawMenuBar member of your CMainFrame class. If you are doing the enable/disable in a class other than CMainFrame, you can do this:
AfxGetMainWnd()->DrawMenuBar();
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
Is there a way to add tool tip text for a button that was dynamically added to a tool bar?
So far, I have managed to add the button and image but the tool tip never attempts to come up. From what I have seen so far, everything seems to want to use a string resource ID instead of a char* somewhere. Does anyone know if this can be done?
Does anyone know where the tool tip "LoadString()" happens?
thanks,
Dave
|
|
|
|
|
Handle the TTN_NEEDTEXT notification in your CMainFrame class (you have to add it manually, not from ClassWizard). Inside the notification function, you can check what the ID of the item is, and if it's your special toolbar button, you can specify your own text to be displayed. I can set up a small demo if you want.
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
Thank you very, very much. You have just saved an entire day of screwing around. This is exactly what I needed.
|
|
|
|