|
thanks kind of rusty
JLS
Student/Part time programmer
Major Programming.
|
|
|
|
|
How can I change the colour of the text in a button @ run-time.
I tried to override the onctlcolor method:-
HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_BTN)
{
pDC->SetTextColor(RGB(255,0,0));//set red
return (HBRUSH) m_Brush.GetSafeHandle();
};
return hbr;
}
m_Brush is a member brush & in OnInitDialog method, I create it with a solid brush.
m_Brush.CreateSolidBrush(RGB(129,129,129));
Thanks
Gerry.
|
|
|
|
|
Hello all
how do i add TollBar and StatusBar to a dialog window?
thanks
|
|
|
|
|
|
I am trying to make the text bold in a CStatic. I wrote the following code, Can anyone see where i am going wrong.
CFont *M_titleFont is a member varible.
Code Snippet, from oninitdialog:
LOGFONT lf;
m_titleFont->GetLogFont(&lf);
lf.lfWeight = 700; //Set Bold
m_titleFont->CreateFontIndirect(&lf);
Cheers
Rich
|
|
|
|
|
|
Oops Missed That Bit Out!
m_titleFont= GetDlgItem(IDC_TITLE)->GetFont();
Thanks Again
Rich
|
|
|
|
|
I found I had problems using CreateFontIndirect() with an existing font. But it was easier to create a new font instead.
LOGFONT lf;
m_titleFont->GetLogFont(&lf);
lf.lfWeight = 700; //Set Bold
CFont boldFont;
bolFont.CreateFontIndirect(&lf);
// continue to use boldFont
Hope this helps. =)
=)
|
|
|
|
|
Hello,
I am having a trouble using the SQLConfigDataSource() method. I can call it successfully with the code below:
CString sDriver;
sDriver.LoadString(IDS_SYBASE_DRIVER);
bSuccess = SQLConfigDataSource(NULL,ODBC_ADD_DSN,sDriver,
"DSN=123\0"
"DatabaseName=123\0"
"DatabaseFile=E:\\junk.db\0"
);
But when I try to put the connection string into a CString or the string table, the string gets reduced to "DSN=123" due to the required '\0' value separator. I would like to create a format string like "DSN=%s\0DatabaseName=%s\0DatabaseFile=%s\0" so can create a custom ODBC database.
Any ideas on how to do this?
Thanks in advance!
Derek
|
|
|
|
|
I would like to create a format string like "DSN=%s\0DatabaseName=%s\0DatabaseFile=%s\0"
This doesn't work because the first \0 is interpreted as the end of the format string. AFAIK neither the C string APIs nor CString support embedded null characters. BSTRs do support them, but working with plain BSTRs is a hassle, and CComBSTR doesn't handle embedded nulls well.
What I usually do is use some other unique separator like '|' when building the string, then loop thru the string and replace '|' with '\0'.
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
I understand what you mean by looping through to replace the temporary separator ('|') with the required separator ('\0'), but what do you use to hold the connection string? If I use a '|'-delimited CString and then loop through and replace them with '\0', aren't I in the same boat I was before? Won't the CString still cut the string at the first NULL?
|
|
|
|
|
Won't the CString still cut the string at the first NULL?
hmm... If you absolutely must have your string in a CString, that might be tricky. C-style strings (and thus CStrings) just don't allow embedded nulls, so forcing yourself into using CString is just going to make headaches for you. Is there some specific reason you want to use CString?
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
Absolutely not. I'm just so used to its functionality that I always grab for it first.
It sounds like you've done this before. How did you do it?
Thanks again!
|
|
|
|
|
I just make a big char array and do the procedure I described earlier.
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
I just wanted to thank you for all your help. I ended up using a
vector lt;chargt; which worked great.
Thanks again!
|
|
|
|
|
I just wanted to thank you for all your help. I ended up using a vector<char> which worked great.
Thanks again!
|
|
|
|
|
You can also use std::string - one of the biggest differences between std::string and CString is that std::string does NOT interpret a '\0' as the end of string, so it fully supports strings containing embedded NULLs.
|
|
|
|
|
Just for the heck of it, I tried the std::string method. I had solved this using a vector<char>, but the string method looks a little cleaner. However, I couldn't get it to work with SQLConfigDataSource(). Here's the code:
CString sSybaseDriver,sSybaseConfig;
sSybaseDriver.LoadString(IDS_SYBASE_ODBC_DRIVER);
sSybaseConfig.Format(IDS_SYBASE_ODBC_ADD_DSN);
std::string sConfig(sSybaseConfig);
std::replace(sConfig.begin(),sConfig.end(),'|','\0');
BOOL bSuccess = SQLConfigDataSource(NULL,ODBC_ADD_DSN,sSybaseDriver,sConfig));
The compiler first complained that it couldn't convert a string to const char * for the last parameter in SQLConfigDataSource(). So I changed it to:
BOOL bSuccess = SQLConfigDataSource(NULL,ODBC_ADD_DSN,sSybaseDriver,sConfig.c_str()));
It compiled, but the call to SQLConfigDataSource() failed. The vector<char> is a little messy, but at least it works.
Any ideas on how to get the string version to work or should I just be happy that I found a solution?
Thanks,
Derek
|
|
|
|
|
Derek. The string sConfig must be the following format.
"DSN=Personnel Data\0UID=Smith\0PWD=Sesame\0DATABASE=Personnel\0\0"
With Double \0 in the finish. this is very important
Did you do that?
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
That was it!!
Thanks for all the help!
Derek
|
|
|
|
|
when i put (at design time) a RichEdit control on a dialog i cant see the while dialog when i build and run the project.
why? and how can i solve this?
|
|
|
|
|
You must call AfxOleInit() and AfxInitRichEdit()
in InitInstance() of your CWinApp object.
Good luck
|
|
|
|
|
|
Hi,
I've implemented a system tray icon for my app and I want to have a popup menu for it. I have a message handler created to catch when the user right clicks my icon in the system tray. When this function runs, how should i determine where to place the pop up menu? I can't find a way of determining where the mouse pointer currently is?!?!
Thanks once again
Jay
|
|
|
|
|