|
There are a number of ways of letting a program know that something happened. They vary in complexity and flexibility. Some of them are:
- callback functions
- posting a custom message to a window
- posting WM_COPYDATA to send data + notification
Hope this helps and that I'm not stating the obvious.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
posting WM_COPYDATA to send data + notification
Hey thanks for that! That's what I love about this site - you constantly pick up little scraps of information that will prove useful.
________________
David Wulff
http://www.davidwulff.co.uk
"I loathe people who keep dogs. They are cowards who haven't got the guts to bite people themselves" - August Strindberg
|
|
|
|
|
Posting (PostMessage) a WM_COPYDATA message is NOT recommended.
Use SendMessage or SendMessageTimeout instead.
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|
|
Gert is absolutely right. Use SendMessage() instead of PostMessage() when delivering WM_COPYDATA. My mistake!
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I guess you could give the dll an interface to the main program. Just a pointer to an instance of some class with some functions to process input from the dll. This is the way 3d Studio VIZ handles plugins.
WAVK
|
|
|
|
|
I've done it a different way (but thanks to all who answered). When I call the Init function in the .DLL I pass the handle of the window of my prog. Then the key function just sends a message to the main program that a key was just pressed. I use ::PostMessage(), and if I lose a key every now and then, it won't be missed among the million-or-so other keys a month I type.
I can't wait to actually get this project going because I want to start letting the world know about it!
-Jason
nirgle.bitdevil.com
|
|
|
|
|
I'm trying to look for some tuts or sample apps that use radio buttons. Ihave 2 radio buttons on my dialog, and need to disable certain controls when one or the other is selected, depending on what is selected.
If anyone knows of any good sites that may have what I'm looking for or if anyone could provide insight or maybe a quick sample about what I'm trying to do, I would really Appreciate it.
Thanks so much in advance.
Digital Khaos
"Every problem has a solution" --unknown
|
|
|
|
|
Go to the resource editor, and make sure you have the wizard bar visible. Click on a radio button and the drop down will let you add an OnClick handler for that button, which you can then use to enable/disable items to your hearts content.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
OK, I suppose I'm looking for an API function or MFC function that is actually responsible for disabling controls?
Digital Khaos
"Every problem has a solution"
|
|
|
|
|
Well, you didn't say you needed to know *that* part as well.
Every CWnd derived class has a method called EnableWindow, which takes a BOOL.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
OK, you'll have to pardon my lack of knowledge but doesn't EnableWindow() actually enable/disable the entire window? Where as I'm looking to enable/disable only a specific control in the window. Unknowingly i did:
void CPro1WinTUSDlg::OnMainDataRadio()
{
EnableWindow(IDC_EDIT1==TRUE); // or FALSE
}
As you know, whis doesn't produce the correct results. It actually disables my entire program, or at least locks it up (heh).
Sooooo, am I doing something wrong or do I need to use a different function?
Thanks!!!
Digital Khaos
"Every problem has a solution"
|
|
|
|
|
Yes, you want to disable the control, which is also CWnd derived. So you need to create variables that map to your controls and then call EnableWindow on them.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Do this:-
GetDlgItem (IDC_EDIT1)->EnableWindow(FALSE)
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I tend not to use GetDlgItem, but you're right, given the method you want is in the base class, it's as good a way of doing it.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Yeah, true. After raeding a couple of articles by Joe Newcomer I have always tried to avoid GetDlgItem and UpdateData in my code, specially being a big fan of Joe, that I am.
A lot of people seem to forget that we can use class wizard to create control variables for our dialog controls. I mean most people would have associated CStrings with text boxes but how many associate an edit box with a CEdit?
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
It was Paul DeLascia who pointed it out to me, in an MSJ article.
Nish [BusterBoy] wrote:
I mean most people would have associated CStrings with text boxes but how many associate an edit box with a CEdit?
I almost *always* associate with a control, not a variable. Then I can roll my own data validation, which is always better than the rubbish MFC comes out with.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I use GetDlgItem and UpdateData all over my code for too many years. I haven't read Joe's writings on why they're bad. Can you briefly tell me the problem?
I guess it's habit - it's how I was shown a long time ago. It appears to work well though. Is it considered bad style now?
thx
|
|
|
|
|
See these two articles by Joe :-
http://www.codeproject.com/cpp/nogetdlgitem.asp
http://www.codeproject.com/cpp/avoidupdatedata.asp
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
What if I want to add,delete,update resources in my exe file on Windows 9x.
The APIs BeginUpdateResource only work on WinNT and others.
So is there any way that my exe file can update resources of another exe.
Plz help me if you know.
In my dream, I was dorwning in my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
Erik Kallen has written an impresive clone of this APIs working in Win9x systems. Check his article Updating Resources on Win9x.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanx
In my dream, I was dorwning in my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
Hi Guys,
i am creating an app with a doc/view architecture. The base class of my view class is CListView. Now i am using the InsertColumn function of CListCtrl. After that i am inserting some strings with the InsertItem function. The problem now us that i am changing the font, and the font of the Column also changes. WHY ?? I want that the Column Font stay always same and only the inserted String font wwould be changed...
Please see code:
void CFVCtrlView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl &lCtrl=GetListCtrl();
lCtrl.InsertColumn(0,"Header",LVCFMT_LEFT,300);
lCtrl.ModifyStyle(0, LVS_SORTASCENDING | LVS_REPORT | LVS_EX_FULLROWSELECT );
lCtrl.SetBkColor(RGB(160, 184, 207));
}
.
.
.
void CFVCtrlView::SetFonts()
{
CListCtrl &lCtrl=GetListCtrl();
CFont *font=(CFont *)this;
font->CreatePointFont(100,"arial");
lCtrl.SetFont(font);
lCtrl.InsertItem(1,"Hello World",0);
}
Please help if anybody can...
Its really urgent.
regards
sonu
|
|
|
|
|
It's really obvious when you think about it - you've set the font for the list control, so the list control uses that font.
I don't know of any way to fix this apart from making the list owner drawn and storing a font, or font details, for each cell that doesn't use the standard font of the control as a whole. That doesn't mean there *isn't* another way, I've never tried to do what you're doing.
Chris's grid control in a form view may provide the answer, I'm not sure if it does per cell fonts or not.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
How can I change the title caption of a dialog (CDialog) object?
I want to do the following:
CSetupDlg::OnShowSummary()
{
CString sMyTitle;
CSummaryDlg dlg;
// Somehow, set the title of the Summary Dialog
// with sMyTitle, today's date, or "The Summary is..."
dlg.doModal(); // I might use modeless case - must work both ways.
}
Thanks all!
Happy Holidays (BTW, http://www.crackermatic.com was funny )
|
|
|
|
|
SetWindowText on the dialog.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|