|
string.TrimRight("\r\n");
|
|
|
|
|
Well. You will have to walk through the CString object and split the sections. Use the Find() and Mid() function for the CString object.
Kuphryn
|
|
|
|
|
isn't Trimright more efficient?
|
|
|
|
|
The Trim() functions are useful, however, they will remove all the ends off. Thus using TrimRight() will work for for the first occurance of "/r/n," but then you will lose all texts after it.
Kuphryn
|
|
|
|
|
exactly what was asked for. also TrimRight will not need to run a copy ctor, it changes length of the CString IMHO.
|
|
|
|
|
I know how to implement a UI handler for a toolbar button in my CView class, e.g.:
//////////////////////////////////////////
void CFooView::OnUpdateToolbarFooUI(CCmdUI* pCmdUI)
{
if (blah-de-blah)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
/////////////////////////////////////////
Question is, how to do I get the proper toolbar button CCmdUI pointer in calling OnUpdateToolbarFooUI()? Is there a function I can call?
Thanks so much... I've been going nutty over this problem
|
|
|
|
|
I'm kinda a beginner so this might not be right but I think you need to implement a UI update handler for each toolbar button that you want to update. So in your message map you'd have something like:
ON_UPDATE_COMMAND_UI (IDC_TOOBARBUTTON1, OnUpdateToolbarButton1) and you implement it as follows:
void CFooView::OnUpdateToolbarButton1(CCmdUI* pCmdUI)
{
if (blah-de-blah)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
} or you can use an ON_UPDATE_COMMAND_UI_RANGE handler if your toolbar buttons are all numbered contiguously. It's form is as follows:
ON_UPDATE_COMMAND_UI_RANCE (idStart, idEnd, OnUpdateToolbarRange) where idStart is the first command ID in the range and idEnd is the last command ID in the range. I think the message handler should be implemented as:
void CFooView::OnUpdateToolbarRange(UINT idToUpdate, CCmdUI* pCmdUI) I'm not sure if the implementation above ^ is the correct way to define the handler so I'd double check the help.
Hope this helps.
- Monrobot13
|
|
|
|
|
I see... thanks for your help.
I actually came across a revelation: my program is actually calling CFooView::OnUpdateToolbarButton1 "automatically" when appropriate-- I don't even need to call the function.
I am guessing this is because whenever this button's state is to be enabled or disabled, I am also concurrently doing an entire window Invalidate(), which is calling the UI function. (Anyone know if this guess is correct?)
Well, problem fixed, in any case. Thanks for your help!
|
|
|
|
|
can i creat a __gc pointer and call its methods in a __nogc callback function?
r00d0034@yahoo.com
|
|
|
|
|
In my app, a dll sends a send/postmessage to the calling app. This is failing for some reason. I am sending a PBM_STEPIT message to a progressbar. What I want to check is to see if a simple sendmessage is also failing or if it works. What kind of message can I send (simplest) to my calling app just to see if sendmessage works?
Thanks,
ns
|
|
|
|
|
Are you catching the message in the calling app using a message handler, event, or switch statement (in the WinProc)?
Jason Henderson start page articles "If you are going through hell, keep going." - Sir Winston Churchill
|
|
|
|
|
I only know how to make a handler in the calling app that gets triggered by the sendmessage. I was hoping to avoid the user defined messages and maybe take advantage of a simpler one I could send to a button or something. I'm trying that now ---A WM_COMMAND.
Thanks,
ns
Well, I tried triggering the buttons handler in the calling app, but that gave me a com error as well (something goes wrong at the sendmessage call in the dll, and a messgaebox immediately after the sendmessage never gets triggered (this is in the dll). THE client manifests this as a com error at the function call:
try
{
CoInitialize(NULL);
_Class1Ptr ptr;
ptr.CreateInstance(__uuidof(Class1));
long lHwnd=(long)m_messagebutton.GetSafeHwnd();
ptr->CheckingPB(&lHwnd);
}
catch(_com_error &e)
{
bstrDesc = e.Description();
}
The dll has:
Public Function CheckingPB(PbarHandle As Long)
result = SendMessage(PbarHandle, WM_COMMAND, 0, 0)
|
|
|
|
|
ns wrote:
SendMessage(PbarHandle, WM_COMMAND, 0, 0)
The 3rd arg to SendMessage is the wParam (i.e. the command id). You probably don't want to it to be zero.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have to use the SendMessage API in the VB dll, which takes the handle of the receiving window. Are you perhaps talking about the CWnd::SendMessage?
|
|
|
|
|
ns wrote:
Are you perhaps talking about the CWnd::SendMessage?
Yes. Are you saying that the SendMessage args following WM_COMMAND are different between MFC and VB?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
SendMessage, the raw API is not the same as CWnd::SendMessage in terms of argument lists.
Thanks,
ns
|
|
|
|
|
I'm trying to setup a tracker control so that the top if the max, and the bottom is the min. It makes sense then to use TBS_DOWNISLEFT style, so I use that when creating the window. But it doesn't work (On Win2k). No matter, the top if always 0 and the bottom is always the max, with or without the flag. What's going on here??
HWND hSlider;
if (!(hSlider=CreateWindowEx(0,TRACKBAR_CLASS,"",TBS_DOWNISLEFT | TBS_VERT | TBS_NOTICKS | WS_VISIBLE | WS_CHILD,0,0,30,200,hWnd,(HMENU)1,hInst,0)))
return -1;
SendMessage(hSlider,TBM_SETRANGEMIN,0,0);
SendMessage(hSlider,TBM_SETRANGEMAX,0,100);
SendMessage(hSlider,TBM_SETPOS,1,50);
|
|
|
|
|
Now my app is just flooding with user breakpoints everywhere. I've checked if i'm freeing some memory that's already freed but no. And most of the time the user breakpoint comes when i'm in an API function so i can't debug inside the function.
Thanks
|
|
|
|
|
You are observing a symptom of some other problem. Probably you are passing bad data into an API function. Work your way back up the call stack 'till it's in your own code, and check for things like de-allocated memory being used, or bogus pointers.
Shog9
------
If you really what to get shitfacde tell a crowded bar that is is yourt borthday and hife your wallet. you ka will many more friends.
- David Wulff, Brithday selebrations, 9/19/02
|
|
|
|
|
if you allocate memory, then write something to it plus 1 byte or more. You could have a "user breakpoint" when you'll free the memory block.
|
|
|
|
|
Hi
I use odbc-access driver in c++ and have a crecordset, created with the adress of a database. I can use my CRecordset-pointer m_pRS to navigate through the set, but whenever i want to edit, update, add or delete something from the recordset (like m_pRS->Edit(); ) i get a debug assertion failure (visual c++ 6.00)
Here is the initializing code for the recordset:
<br />
CRecordset *rs = new CRecordset(&m_DB);<br />
m_pRS = rs;<br />
m_hStmt = m_pRS->m_hstmt;;<br />
<br />
SDWORD b1;<br />
SDWORD b2;<br />
<br />
SQLBindCol (m_hStmt, 1, SQL_C_CHAR, (PTR)m_mAkt.m_sName, sizeof(m_mAkt.m_sName), &b1);<br />
SQLBindCol (m_hStmt, 2, SQL_C_DOUBLE, (PTR)&m_mAkt.m_fDichte, sizeof(m_mAkt.m_fDichte), &b2);<br />
SQLBindCol (m_hStmt, 3, SQL_C_CHAR, (PTR)m_mAkt.m_sBeschreibung, sizeof(m_mAkt.m_sBeschreibung), &b1);<br />
<br />
<br />
try<br />
{<br />
m_pRS->Open( CRecordset::snapshot, <br />
_T("SELECT * FROM Material ORDER BY Materialname, Dichte"),<br />
CRecordset::none);<br />
<br />
GetMaterialNum();<br />
}<br />
catch ( CDBException *pDBE)<br />
{<br />
AfxMessageBox("Database Fehler: "+pDBE->m_strError); <br />
return false;<br />
} <br />
<br />
Can someone help me why navigating (calling for example m_pRS.MoveNext(); )works, but not .Edit() , .Update(), .AddNew and so on?
Thank you
niklas
|
|
|
|
|
How do I place a hypertext link in my about dialog in mfc ?
Thanks!
|
|
|
|
|
|
Uwe Keim wrote:
http://codeproject.com/miscctrl/hyperlink.asp[^]
what do you think about the comments from "AnthonyJ" about:
"open" with new IE window?
Is the described code a portable (running Win9x-XP) to open a URL in a new window? I haven't searched Google yet, but I'm curious.
|
|
|
|
|
Hello there,
I'm sure all of you read some articles about C++ .NET !
And when i always ask you about it, you say: "Everything is improved in C++ .NET, MFC and ATL and etc is improved."
But now, i want to know Did you switch on it ?
Do you use C++ .NET instead of VC++ 6.0 ?
What's your programming language, right now ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|