|
Thanks, that answered my question about the background color, but id does not help me with setting the static text text color ... any suggestions.
Thanks ~
|
|
|
|
|
Read up on the CDC functions (or equivalent Win32 APIs if you're not using MFC). SetTextColor will, as the name says, set the text color.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
How can we over ride the WindowProc() in an ATL composite control. I need this to add hot keys to my application.
Thanks in advance,
Rejeesh.
|
|
|
|
|
ok so i make an app shell and put in a flexgrid control.
the grid is 7x7
here's my prob:
-the first column is static, never changes. i need to put in 7 labels.
-the second column will change, it contains dollar values i.e $400.00. the information in this column repeats itself across the span of the remaining columns.
-i need 1 button to display the dollor values and 1 button to clear them leaving the first column unchanged.
i've tried useing an example for this but it uses a random generator and i can't get the items to appear in the order i want them in. please help!!
|
|
|
|
|
I have a Win32 application which has a toolbar, dropdown menu, and utilizes hotkeys.
I enable/disable buttons on my toolbar/menu based on certain criteria which is changed during program execution.
Where is the best place in my code to tell the toolbar/menu to make desicions about enabling/disabling buttons? It seems a bit messy to call my Toolbar_Update() function everytime something is executed from the menu or toolbar.
Is there some kind of call back or something I could use?
I mean, calling this Update function everytime does the trick, but I'm not sure that its all that clean.
Mike.
doner@obtain.com
|
|
|
|
|
You could set up an idle message loop to do your updates ( in your main message loop ), this is the most common way I've seen it done ( MFC/WTL/OWL do it this way ).
Thought the way your curently doing it is just as good as any.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Hi again. Man, I can't get anything working today. I am getting a FILETIME back from my file search and I want to convert it into a DATE to pass into ADO ( if it is important I am using Jet and created a DATE field in Access ). Can anyone give me any hints on how to convert between these two formats ? Or should I just store the date as a number as it comes out of my file search ?
Ta.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
You could rip the conversion function off from the MFC sources, its located in "olevar.cpp" : line # 1568 ().
It takes the form;
_AfxOleDateFromTm ( WORD wYear, WORD wMonth, WORD wDay,
WORD wHour, WORD wMinute, WORD wSecond, DATE & dtDest )
>>> [Update]
You'll also have to use FileTimeToLocalFileTime() and FileTimeToSystemTime() to get a usable date structure ( namely SYSTEMTIME ).
FILETIME fileTime; <br />
<br />
FILETIME localTime;<br />
FileTimeToLocalFileTime ( &fileTime, &localTime );<br />
<br />
SYSTEMTIME sysTime;<br />
FileTimeToSystemTime ( &localTime, &sysTime );<br />
<br />
DATE theDate;<br />
_AfxOleDateFromTm ( stCreate.wYear, stCreate.wMonth, stCreate.wDay,<br />
stCreate.wHour, stCreate.wMinute, stCreate.wSecond, theDate );
<<< [Update]
Hope this helps.
Have a good one,
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Christian, is easy, convert the FILETIME to COleDateTime then convert the COleDateTime to variant for send to Ado.
Please Christian see in the classes that I sent you, you can see that conversion in the method SetFieldValue....
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
I have got filtering working in my recordset but I have some real problems.
1/ I'm not sure how all the string types/functions fit together. I've read the chapter in ATL Internals, but it does not appear to have gelled. I'm trying this:
CComBSTR bstrPath;
(*it)->get_FilePath(&bstrPath);
char * pStr = new char[bstrPath.Length() + 20];
memset(pStr, 0, bstrPath.Length() + 20);
sprintf(pStr, "FilePath = '%s'", (_bstr_t)bstrPath);
MessageBox(NULL, pStr, "", 0);
If I
ATLTRACE(bstrPath) the value coming in is OK, but the value in the message box is garbage. What am I missing ?
Also, I get my string together like this:
CComBSTR query = "FilePath = '";
query.Append(bstrPath.Copy());
query.Append("'");
records->Filter = (_bstr_t)query;
Now my string is as I want it to be, but the program crashes on the Filter call. I know I'll get a crash if I pass in bad SQL, but if I pass in the same string verbatim, it works fine. What's wrong with passing in the string as a variable, with the same value ? If I do this:
_bstr_t bquery = "FilePath = 'f:\\biblio1.mdb'";
records->Filter = bquery;
then it appears to work fine, so I presume it's back to me not getting the string thing...
Please help - I'm going mad here.....
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Hi Chris!!!
I Know you.....
What happens with
"FilePath = \"f:\\biblio1.mdb\"";
You can see that I change the ' with ". Some databases are a little ..(I don't know the word) but for example when you use a string that is greatter than 30 characteres is better to use "" and not ''. The SQL Server cut the words in that case.
Carlos Antollini.
|
|
|
|
|
Thanks for trying to help, but it makes no difference if I use single or double quotes - if I use the code that builds a search string, the string is exactly what I would pass in, but if I pass it in manually or through a _bstr_t object I create in one line (_bstr_t t = blah blah ) then it works, but if I build the string using my variable the string is the same and the program crashes.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
When I make a cast to _bstr_t I always use
_bstr_t(str); //when str is for example a CString.
I suspect that you have a problem in the sprintf.
I saw that you pass a parameter making a cast to _bstr_t. I think that is better to make a cast to (LPCTSTR) in the sprinf....
I hope to help you Christian...
Carlos Antollini.
|
|
|
|
|
Thanks - now the sprintf is returning the right result and I pass it in like this:
records->Filter = (_bstr_t)pStr;
This still crashes in the Filter() command, although the string going in is still exactly the same string I have previously created in a single line and passed in. I've tried \n and \0 on the end of the string to no avail.
Thanks for helping
Christian
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
It would appear the ADO error only occurs if there are spaces in the field. How do I get around that ? I've put them in quotes (tried single AND double)...
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I know that problem.
In DAO the engine supports the names with space but using this notacion [Field Name] but in ADO I saw that this don't work. Is for this that Always I use the name of the Fields without spaces. If is necesary I prefer to use Under score => _
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
>>>
CComBSTR bstrPath;
(*it)->get_FilePath(&bstrPath);
char * pStr = new char[bstrPath.Length() + 20];
memset(pStr, 0, bstrPath.Length() + 20);
sprintf(pStr, "FilePath = '%s'", (_bstr_t)bstrPath);
MessageBox(NULL, pStr, "", 0);
<<<
try this;
sprintf(pStr, "FilePath = '%s'", (char*)(_bstr_t)bstrPath);
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Thanks - that works, but this line:
records->Filter = (_bstr_t)pStr;
still crashes. The string works if I pass it in manually or through a seperate _bstr_t. Creating a _bstr_t from pStr does not help.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
What is 'records', or actually beter yet, what does type is 'Filter'.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Records is a _RecordsetPtr. I am in ATL, no MFC support. The filter method of the Recordset works perfectly if I pass in the same string, but hard coded or created as a _bstr_t from a hardcoded value. The program crashes if I try it with the variable, if I use try/catch I get a meaningless error.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
That line crashes because (_bstr_t)pStr creates a temporary _bstr_t object which then gets deleted right away. That leaves records->Filter pointing at invalid memory. (This assumes records->Filter is a BSTR or other pointer type.)
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
It's a _variant_t, but even if I create the _bstr_t seperately, it still crashes. I am certain it crashes because ADO does not recognise the command as valid, even though the syntax is the same when I pass in a hard coded value and it works.
_bstr_t s = pStr;
records->Filter = s;
Crashes
_bstr_t s = "FilePath = 'f:\\bibloi1.mdb'";
records->Filter = s;
works, even though the string I bring up in a MessageBox ( pStr) is exactly the same.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I'm guessing you've already tried this, but maybe a little sanity check is in order;
_bstr_t s = pStr;
_bstr_t s2 = "FilePath = 'f:\\bibloi1.mdb'";
if ( s == s2 ) {
MessageBox ( "They are the same!!!");
}
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
It would appear the ADO error only occurs if there are spaces in the field. How do I get around that ? I've put them in quotes (tried single AND double)...
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
You have probably already figured this out, but if your DB allows spaces in field names (e.g. Access) most impls I've seen (i.e. Access) want you to surround them with [] brackets.
Careful though - SQL Server (which doesn't allow spaces, AFIK) will err out on you if you try to add the [].
It may be almost a rule of thumb that if you retrieve a field or table name that has an 0x20 in it you should slap the []s on 'em, and let 'em go otherwise.
|
|
|
|