|
You have probably done this but MSDN suggests that instead of /PDB:NONE you use /Zi. From the description it sounds like they do the same thing.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
I want a button to diplay the red text sometime, so I create a class derived from CButton and override the OnCtlColor handler, as below:
HBRUSH CColorButton::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CButton::OnCtlColor(pDC, pWnd, nCtlColor);
if(m_iFlag == 1)
pDC->SetTextColor(0x000000ff);
return hbr;
}
but I found the handler didn't be executed even when the dialog initialized,
How can I do the work I want.
Thanx.
|
|
|
|
|
|
Thank you.
I saw the source code and found the way he accomplished the work seamed the same as mine.
I just wonder why my overrided message handler OnCtlColor didn't be executed, as I set a break point in the handler, no stoping occured when I debuged.
|
|
|
|
|
Are you using ON_WM_CTLCOLOR() or ON_WM_CTLCOLOR_REFLECT() in your message map? Since your OnCtlColor() function is in your button, you need to use ON_WM_CTLCOLOR_REFLECT() . If you're not, just replace the message map entry and it will work fine.
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"
|
|
|
|
|
Yeth, I also found that is the point just now. It seems that the ON_WM_CTLCOLOR message could only be managed by parent wnd, I replaced it with ON_WM_CTLCOLOR_REFLECT and overrided CtlColor() (not OnCtlColor) and it worked.
Thank you.
Does it means only I need is to manage the ON_WM_CTLCOLOR_REFLECT message but ON_WM_CTLCOLOR?
|
|
|
|
|
You don't need ON_WM_CTLCOLOR() , only ON_WM_CTLCOLOR_REFLECT()
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"
|
|
|
|
|
Olinn
Have a look at the msdn article Visual C++/MFC Frequently Asked Questions, in the MSDN library. I haven't got the web link, but the extract is shown below:
How do I change the background color of a button?
Note: the method in "How do I change the background color of a control?" will not work for buttons!
If you want to change the color of a dialog button, you have to use an owner-draw button. (You can use bitmap buttons.) Changing the color through OnCtlColor() will not work for buttons. The following Knowledge Base articles may be of help to you: Q32685, "Using the WM_CTLCOLOR Message," and Q64328, "SAMPLE: Owner-Draw: 3-D Push Button Made from Bitmaps with Text." This article explains sample code for a owner-draw button.
Ramesh (NetQuest), MSMFC, 8/3/95
"..Even my comments have bugs!"
Inspired by Toni78
|
|
|
|
|
1. CAtlMfcModule -
2. afxstr.h -
3. Atlsecurity.h -
Can somebody tell me if these header files and the class are supported in vc++6.0? I guess it should be .Net..
|
|
|
|
|
I don't see those files in my VC6 install... so, probably VC7.
onwards and upwards...
|
|
|
|
|
In an add-in I made for office applications I was able to determine whether I'm working with WORD, EXCEL or POWERPOINT by using the GetIDsOfNames function on the application, while rgszNames = "Name".
STDMETHOD ( GetIDsOfNames )(
REFIID riid,
LPOLESTR* rgszNames,
UINT cNames,
LCID lcid,
DISPID* rgdispid );
While working with WORD I was able to retrieve the file name and path by further use of this function:
The active document was retrieved by using the function
on the application, while while
rgszNames = "ActiveDocument".
The document name was retrieved by using the function
on the active document, while while rgszNames = "Name".
The document's file path was retrieved by using the
function on the active document, while while
rgszNames = "Path".
While working with EXCEL I was able to retrieve only the WorkBooks by using the function on the application, while while rgszNames = "WorkBooks".
All this was done in the trial and error system.
I'd appreciate it very much if someone could refer me to a list of values that can be sent as the rgszNames parameter and/or explain how to retrieve the file path and name while working with EXCEL and POWERPOINT.
thanx
|
|
|
|
|
|
Which property? Name, size, date, owner, attribute, etc?
|
|
|
|
|
my question too -- exactly which properties. Properties about the file?
Or, do you speak of specific properties stored in an OLE DOCFILE(IStorage/IStream)?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Thank you for your reply.. I need to know the application name of the file which doesn't have an extension.
I have the following code and it only work for MS Office files but not for others like .tiff, .txt, pdf..etc
if the file is not MS Office files, then the hr = pPropSet->Open(FMTID_Summary.... set the hr to FAILED.
It never get executed DumpBuiltInProps(pPropStg,appname);
<br />
bool GetAppName(char* filename,char *appname)<br />
{<br />
WCHAR wcFilename[1024];<br />
setlocale( LC_ALL, "" );<br />
int i = mbstowcs(wcFilename, filename, strlen(filename));<br />
setlocale( LC_ALL, "C" );<br />
wcFilename[i] = 0;<br />
<br />
HRESULT hr = S_OK;<br />
IStorage* pStg = NULL;<br />
hr = ::StgOpenStorageEx(wcFilename, STGM_READWRITE | STGM_TRANSACTED, STGFMT_DOCFILE, 0, NULL, NULL, IID_IStorage, (void**)&pStg);<br />
if(FAILED(hr))<br />
{<br />
hr = ::StgOpenStorageEx(wcFilename, STGM_READWRITE | STGM_TRANSACTED, STGFMT_ANY, 0, NULL, NULL, IID_IStorage, (void**)&pStg);<br />
if(FAILED (hr))<br />
return false;<br />
}<br />
<br />
IPropertySetStorage* pPropSet = NULL;<br />
hr = pStg->QueryInterface(IID_IPropertySetStorage, (void**)&pPropSet);<br />
if(FAILED(hr))<br />
{<br />
pStg->Release();<br />
return false;<br />
}<br />
<br />
IPropertyStorage *pPropStg = NULL;<br />
<font color=red> hr = pPropSet->Open(FMTID_SummaryInformation,STGM_READ|STGM_SHARE_EXCLUSIVE,&pPropStg);<br />
if(FAILED(hr))<br />
{<br />
pPropSet->Release();<br />
pStg->Release();<br />
return false;<br />
}</font><br />
DumpBuiltInProps(pPropStg,appname);<br />
<br />
pPropSet->Release();<br />
pStg->Release();<br />
return true;<br />
<br />
<br />
}<br />
|
|
|
|
|
The code that you have works for programs that employ the OLE2 DOCFILE format. DOCFILE is a filesystem within a file.... It's a container system that stores virtual-file and virtual-directories within a single file.
The DOCFILE also has the ability to store a "summary" table -- represented by IPropertyStorage.
This kinda thing only works for DOCFILES. Other files are more difficult.
You CAN look into the registry (HKEY_CLASSES_ROOT), to find out what program is associated with your file extension. But if you don't have a file extension, then you're in trouble.
Without a file extension, I expect that you'd have to open the file to manually detect the format. (a pretty limited solution).
As a bit of unrelated trivia -- the Mac handles file associations without using filename extensions. They do all of this by saving useful data into the "resource fork" of the file. All files in the mac file system have a resource fork (I think)....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Try this:
bool GetAppName(char* filename,char *appname)
{
WCHAR wcFilename[1024];
setlocale( LC_ALL, "" );
int i = mbstowcs(wcFilename, filename, strlen(filename));
setlocale( LC_ALL, "C" );
wcFilename[i] = 0;
HRESULT hr = S_OK;
IPropertySetStorage* pStg = NULL;
hr = ::StgOpenStorageEx(wcFilename, STGM_READWRITE | STGM_TRANSACTED, STGFMT_DOCFILE, 0, NULL, NULL, IID_IStorage, (void**)&pStg);
if(FAILED(hr))
{
hr = ::StgOpenStorageEx(wcFilename, STGM_READWRITE | STGM_TRANSACTED, STGFMT_ANY, 0, NULL, NULL, IID_IStorage, (void**)&pStg);
if(FAILED (hr))
return false;
}
IPropertyStorage *pPropStg = NULL;
hr = pStg->Open(FMTID_SummaryInformation,STGM_READ|STGM_SHARE_EXCLUSIVE,&pPropStg);
if(FAILED(hr))
{
pPropSet->Release();
pStg->Release();
return false;
}
DumpBuiltInProps(pPropStg, appname);
pPropSet->Release();
pStg->Release();
return true;
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I am trying to create an array of structures.
The structure that I have created looks like this:
<br />
<br />
struct TSimSignal<br />
{<br />
<br />
double Value[45];<br />
int SimWriteFlag;<br />
int data_index;<br />
int DisplayReadFlag;<br />
long TimeStamp;<br />
<br />
};<br />
My program has to write the entire structure to memory so, another program can read that chunk of memory and use the struct.
Here is the array that I created:
<br />
<br />
struct TSimHeader *header_ptr = new TSimHeader[1];<br />
I then try to add the TSimSignal to the array
Is this how you would doo this?
I think my array is an array of pointers to the structs, but How can I create an array that will hold the TSimSignal struct?
Thanks,
sj
|
|
|
|
|
Use a CArray template:
#include "afxtempl.h"
.
.
.
CArray<tsimheader, tsimheader=""> arrayName;
arrayName.SetSize(0,1);
Then you can simly use the the memberfunctions of CArray to Add/Insert/Delete... elements of the type TSimHeader.
Search MSDN for CArray for more info.
Hope that helps
MS
|
|
|
|
|
You can do something like:
struct TSimSignal
{
double Value[45];
int SimWriteFlag;
int data_index;
int DisplayReadFlag;
long TimeStamp;
} TSimSignalArr[10]; or
struct TSimSignal
{
double Value[45];
int SimWriteFlag;
int data_index;
int DisplayReadFlag;
long TimeStamp;
} *TSimSignalArr;
TSimSignalArr = new struct TSimSignal[10];
|
|
|
|
|
David,
I must be doing something wrong because
When I try that I get these errors:
d:\.h(30) : error C2501: 'TSimHeader_arr' : missing storage-class or type specifiers
d:\.h(30) : error C2040: 'TSimHeader_arr' : 'int' differs in levels of indirection from 'struct TSimHeader *'
d:\.h(30) : error C2440: 'initializing' : cannot convert from 'struct TSimHeader *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:\.cpp(164) : error C2275: 'TSimHeader' : illegal use of this type as an expression
d:\.h(20) : see declaration of 'TSimHeader'
I don't know why I get the error about trying to convert a pointer to an int?
<br />
struct TSimHeader<br />
{<br />
char *Name[45];<br />
char *Unit[45];<br />
double Min[45]; <br />
double Max[45]; <br />
int SignalCount; <br />
int SimStatus;<br />
<br />
}*TSimHeader_arr;<br />
<br />
TSimHeader_arr = new struct TSimHeader[10];<br />
Once I have added all the data that I need to the TSimHeader struct I'm trying to put that struct in position 0.
<br />
TSimHeader_arr[0] = TSimHeader;<br />
Thanks David,
your always helpful.
sj
|
|
|
|
|
johnstonsk wrote:
TSimHeader_arr[0] = TSimHeader;
Your TSimHeader variable shouldn't be the same name as the structure. That aside, once you have the members of this variable set accordingly, you need to do individual assignments to TSimHeader_arr[0], like:
TSimHeader_arr[0].Min = TSimHeaderVar.Min;<br />
TSimHeader_arr[0].Max = TSimHeaderVar.Max;<br />
TSimHeader_arr[0].SignalCount = TSimHeaderVar.SignalCount;<br />
etc.
|
|
|
|
|
Right. I did not initially suggest that as I saw no indication that MFC was being used. I use CArray and CList on a regular basis. I hear that std::vector has its merits, too.
|
|
|
|
|
Hi! I'm a beginner and I am trying to make a database program and I am using filters to search something in it.
The user presses the search button and in a new dialog (in edit boxes) the user sees the matching result. This is fine but if there is 2 matching results it just shows the first! How can I make it to show the second one or the third? Can I put a "next" button in the dialog? I saw something like MoveNext() but I don't know how to use it... can someone help me?
Thank you for your future answers!
|
|
|
|
|
Sounds like you need a listbox instead of an edit control. If you must have an edit control, it needs to be multiline.
|
|
|
|
|