|
All I did is I tried to detect right mouse click on richedit control located on my property page. It shoudn't intercept both OnSetActive() and OnKillActive() messages. Please let me know if I did something wrong here.
BOOL CPropertyPage::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
MSGFILTER * lpMsgFilter = (MSGFILTER *)lParam;
if ((wParam == IDC_RICHEDIT1) &&
(lpMsgFilter->nmhdr.code == EN_MSGFILTER)&&
(lpMsgFilter->msg == WM_RBUTTONDOWN))
{
.
.
.
.
}
return CDialog::OnNotify(wParam, lParam, pResult);
}
|
|
|
|
|
Relative C++ and especially VC++ and working with Windows newbie (most previous experience is embedded).
Here's the scenario:
Here's what I want: one class called MonitorClass, and this class should instantiate a bunch of specific montitors underneat underneath it.... monitor1, monitor2, monitor3, etc.....
The "system" will start up the Monitor class which runs in a loop all the time monitoring each specific monitor underneath.
We also have seperate tests that will come into existence that may need to monitor some of the same things....so these tests should go through the MonitorClass to get a Sample() from any specific monitor.
Since we want all to go through the same guy...I'm thinking we want MonitorClass in a DLL (I've never played with DLLs much) so that it is in memory only one time and all go through him.
Can I make a DLL that is essentially a class ? Or must it be nothing more than a collection of functions?
Or...can you understand the problem enough to give a better solution?
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
What are you going to do with the results of the sampling/monitoring? If it is just going to be logged somewhere (file/db), and you always need this running, you may want to consider developing this as a service.
onwards and upwards...
|
|
|
|
|
KingTermite wrote:
Can I make a DLL that is essentially a class ? Or must it be nothing more than a collection of functions?
The DLL can be a collection of exported functions, or it can be a collection of exported classes.
From what you describe, however, I see no reason why you need a DLL. Unless the code needs to be shared between two or more applications, you'd be fine putting it all in one EXE.
|
|
|
|
|
Yes, it was going to be shared by more than one exe.
We talked at more length with the designer of some other code (drivers) being used which was part of the reason we thought we needed it in a seperate DLL anyway.
It turns out the restrictions were not as deep as we thought and we can stick with the static libraries we already have for the monitors.
Thanks for the input all, regardless.
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
Simple answer is "Yes, you can make a DLL export a class". It will tie you into only using one
compiler with that DLL, but this isn't a big restriction most of the time.
You'll want to look up __declspec(export) / __declspec(import) in the MSDN library.
But each instance (EXE / DLL) using your DLL would have a fresh "copy" of the DLL, so you would
get lots of monitors. You can do tricks to make them each refer to a single one, but that gets
a bit too deep.
This sounds like a good project for a COM object. This makes a singleton easier to implement
(look on this site for examples), and means you could use the Monitor from VC++, VB
etc.
I would also think about Event Sinks to inform interested programs of changes in the
real world stuff you are monitoring.
If you have to poll the real world to check on a change, try creating a separate thread which
wakes up at regular intervals briefly.
Good luck, as this is a non-trivial learning curve...
Your experience is the opposite of mine. I've been playing with windows for years, and only
recently had to attack an Arm board...
Iain.
|
|
|
|
|
I want to manage some of my radio buttons and some of my static texts have colored text when the dialog receive a certain message, but other controls donot.
How to do this?
thanx.
|
|
|
|
|
Take a look at CP, there are lots of articles regarding on this in the Static and into other sections...
Hope this helps...
|
|
|
|
|
What is the problem? What do you want to accomplish?
Kuphryn
|
|
|
|
|
make texts of the control or the static text have color
|
|
|
|
|
One solution is to add a handler for ON_WM_CTLCOLOR.
Kuphryn
|
|
|
|
|
Do you mean I should create a new class, inheriting from the orignal control class, for my control which I want to color its text. Then overridde the OnCtlColor function of the class, use CDC::SetTextColor to set the text color?
I am not good at programing, please say it somewhat detailedly.
Thanks a lot!
|
|
|
|
|
olinn wrote:
Do you mean I should create a new class, inheriting from the orignal control class, for my control which I want to color its text. Then overridde the OnCtlColor function of the class, use CDC::SetTextColor to set the text color?
Yes, that would work.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I want to get my curent mouse position. I can't store is from WM_MOUSEMOVE because that just works for the time the mouse is on certain controll. What would be the best way to do this?
|
|
|
|
|
GetCursorPos() gets the current mouse position in screen coordinates.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
And how to I convert this point to a point on the control it's on? There's a function for this too but i just cant remember it's name...
|
|
|
|
|
ScreenToClient()
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I have to get system icon like "my computer" in my program, what can I do?hope to get help from you, TIA
|
|
|
|
|
LPITEMIDLIST pidl;
if(FAILED(SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidl)))
{
}
SHFILEINFO shfi;
if(SHGetFileInfo((LPCTSTR)pidl, 0, &shfi, sizeof(shfi), SHGFI_PIDL | SHGFI_LARGEICON) == 0)
{
}
LPMALLOC lpMalloc;
if(FAILED(SHGetMalloc(&lpMalloc))
{
}
lpMalloc->Free(pidl);
To get the small icon, use SHGFI_SMALLICON instead of SHGFI_LARGEICON.
Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
With Windows 2000, this function SHGetSpecialFolderLocation is superseded by ShGetFolderLocation. but when I use ShGetFolderLocation, system tells me error as follows:
error C2065: 'SHGetFolderLocation' : undeclared identifier
Error executing cl.exe
would you like to tell me how to deal with this problem? TIA
|
|
|
|
|
#define _WIN32_IE 0x0500 before including shlobj.h
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Dear sir:do you have similar example? why cant I make it although I do as you told me a moment ago? my email:tiplip@msn.com, thanks a lot!
|
|
|
|
|
This is a program that compiles perfectly on my system (VC6, Oct02 SDK, WinXP):
#include "stdafx.h"
#define _WIN32_IE 0x0500
#include <shlobj.h>
int __stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
LPITEMIDLIST pidl;
SHGetFolderLocation(NULL, CSIDL_DRIVES, NULL, NULL, &pidl);
return 0;
} It doesn't do actually anything useful so you'll need to fill in the rest from the last example I gave you.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I have been using the getline() to read in lines from a file and delimiting on commas.
I need to set the items in a struct to these values that I read in.
When I get the data from the struct, I get garbage out.
Am I doing this wrong?
Some of the variables that are read in from the file are doubles and I have been using the atof() function to convert from string to double. But, the only way that the struct will allow me to put them in is if I use the c_str() function.
Thanks,
sj
<br />
<br />
<br />
struct TSimSignal<br />
{<br />
double Min[5]; <br />
double Max[5]; <br />
double Value[5]; <br />
string Name[5];<br />
string Unit[5];<br />
};<br />
<br />
<br />
<br />
void setInitialValues(TSimSignal &s){<br />
<br />
string name,unit,min,max,value;<br />
<br />
fin.open("mockData.dat"); <br />
<br />
for(int i=0; i<sizeof(s.Name); i++){<br />
getline(fin, name, ',');<br />
if(name == "STOP")<br />
break;<br />
getline(fin, unit, ',');<br />
getline(fin, min, ',');<br />
getline(fin, max, ',');<br />
getline(fin, value);<br />
<br />
<br />
}<br />
<br />
<br />
}<br />
<br />
|
|
|
|
|
Just a hint. When you're posting code, replace the '<' and '>' with '<' and '>' respectively, otherwise things like your for loop won't turn out properly.
Your code looks correct. Is the data getting loaded correctly? Can you see the values in the strings with debugger before you store it to the struct? Is fin declared as an ifstream ? You might want to post the code with the '<' and '>' changed - it would make it a lot easier to see what it's doing
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|