|
toxcct wrote: not necessary there...
But it is one way.
toxcct wrote: the OP might need to change the caption at any time (not only at the dialog's construction). basically, this->SetWindowText() may be called in any event handler of the dialog itself...
True.
|
|
|
|
|
Hi,
I need to assign hot keys - Ctrl + M etc. to my CToolBar class. How can I do that?
I load the toolbar images, set the separtors and then set the button texts. This toolbar has been created by framework via CMainFrame class.
Any pointers?
Regards
Misha
Be the change you want to see.
|
|
|
|
|
buttons in toolbars are associated with commands/menus.
you will simply need to add an accelerator in the resources.
|
|
|
|
|
Thanks Maximilien,
I added accelerator in the main menu bar. But couldn't add it in the toolbar..
but it works..
Thanks a ton again
Misha Grewal,
Be the change you want to see
|
|
|
|
|
Hello All,
I have a SDI MFC Application created with:
1. Application class derived from CWinApp,
2. Frame window class derived from CFrameWnd,
3. Document class derived from CDocument and
4. View class derived from CView.
I have all the required message maps and handlers in place and required registered doc templete.
My problem is when I bring up the SDI Window and try to write on the window some text, I am not able to even bring the cursor control on to the SDI window.
Please comment.
Thanks and Regds.
Amar.
|
|
|
|
|
While creating your SDI app, make your view class to derive from CEditView instread of CView .
|
|
|
|
|
I have this error "SQL:statement too long" how can i edit what is wrong ?
void CDialogDlg::OnSalveazaCr()
{
CWaitCursor wait; // Display a wait cursor
for(int i=0; i<m_list.getitemcount();i++)
{
="" if(m_list.getcheck(i))
="" {
="" m_log.setwindowtext("log="" -=""> NU exista !!");
CString sTemp,sTemp1,sTemp2,sTip1,sTip2,,sTest1,
sAnul1,sLuna,sLuna1,sZiua1,sData,sValore;
CMainSpace pMainSpace;
pMainSpace.m_sTextDatabase.Empty();
pMainSpace.m_sTextDatabase1.Empty();
pMainSpace.m_sTextDatabase2.Empty();
pMainSpace.m_sTextDatabase3.Empty();
m_cod.GetWindowText(pMainSpace.m_sTextDatabase);
pMainSpace.m_sTextDatabase.TrimLeft();
pMainSpace.m_sTextDatabase.TrimRight();
m_nrCod.GetWindowText(pMainSpace.m_sTextDatabase1);
m_datanota.GetWindowText(sLuna1);
m_datanota3.GetWindowText(sZiua1);
m_datanota1.GetWindowText(sAnul1);
pMainSpace.m_sTextDatabase2 = sLuna1 + "/" + sZiua1 + "/" + sAnul1;
CDatabase_Cod pBun;
pBun.m_strFilter="cod="+ pMainSpace.m_sTextDatabase;
pBun.m_strFilter="nr="+ pMainSpace.m_sTextDatabase1;
pBun.Open();
while (!pBun.IsEOF())
{
int nIndexA = pBun.m_cod.Find(pMainSpace.m_sTextDatabase);
int nIndexB = pBun.m_nr.Find(pMainSpace.m_sTextDatabase1);
if ((nIndexA != -1) & (nIndexB != -1))
{
pBun.Edit();
sTemp = m_list.GetItemText(i,22);
pBun.m_nr = sTemp;
pBun.Update();
pBun.Requery();
pBun.Close();
pBun.Open();
pBun.MoveLast();
pBun.Close();
m_log2.SetWindowText(pBun.m_nr);
m_log.SetWindowText(sTemp);
break;
UpdateData(FALSE);
}
pBun.Close();
break;
//while
}
}
m_list.DeleteItem(i);
i--;
}
}
Bravoone
|
|
|
|
|
Just set a breakpoint and debug your code. Single-step from the breakpoint and check what's happening.
When you know where (in your source code) you get the SQL error, then you probably can figure out how to fix the cause of the problem.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Bravoone_2006 wrote: I have this error "SQL:statement too long"...
How long is it?
Bravoone_2006 wrote: how can i edit what is wrong ?
By shortening the SQL statement.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
how to read the notepad file using vc++
naveen padiyar
|
|
|
|
|
naveen padiyar wrote: how to read the notepad file using vc++
Which notepad file ? You mean '.txt' files ? They are simply text files, so you can open them (with fstream for example) and read the data out of it.
|
|
|
|
|
If you are using MFC, you can perform file read/write operations with the help of CFile class. Read more about CFile on msdn[^]
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Perhaps the question is:
how to read a text file using C++?
Is it?
(Yes) Then you can use C++ fstream class, or C fopen, fread, fclose stuff, or, maybe, MFC CFile class, or, finally, win32 APIs such as OpenFile (hey, you've a lot of alternatives!)
(No) Formulate again (in a more comprehensible way) the question.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Do you want to run NotePad.exe ?
|
|
|
|
|
In my appliaction I've modeless child dialog on the main application dialog. On the child dialog there is a combobox with properties set as:
Type->Drop List; Owner draw->Fixed; Vertical scroll checked.
I've derived a new class from base CComboBox class and overridden the DrawItem method in base class. I used the code available in MSDN inside this method. When I execute the application it gives a runtime error.
Can someone guide me how to solve the problem or implemement the owner drawn combobox ?
The same code works fine when the combobox is used on the main application dialog but not on the modeless dialog.
Please help.
Thanks,
Gajendra
|
|
|
|
|
gajendrakashyap wrote: When I execute the application it gives a runtime error
Where it takes you in the code ?(can you follow callstack).
I dont think, this error related to owner drawn combo box. You must be doing something wrong with other code.
|
|
|
|
|
I'm getting the exception in this call,
dc.DrawText(
lpszText,
strlen(lpszText),
&lpDrawItemStruct->rcItem,
DT_CENTER|DT_SINGLELINE|DT_VCENTER);
I just directly reused the code from "http://msdn2.microsoft.com/en-us/library/y5hb5f9t(VS.80).aspx[^]"
I think you can reproduce the problem with this code.
Regards,
Gajendra
|
|
|
|
|
gajendrakashyap wrote: I think you can reproduce the problem with this code
No, I cant.
Thats why I said, you are doing something wrong.
Can you show how you have created this control, or you have used DDX ?
|
|
|
|
|
Yes I'm using DDX control. I created the ctrl using drag and drop. Then I created the modeless dlg in OnInitDialog()function of Parent wnd as follows.
Modeless_Dlg* ptr_dlg = new Modeless_Dlg();
if(ptr_dlg)
{
ptr_dlg->Create(IDD_DIALOG_MODELESS, this);
ptr_dlg->ShowWindow(TRUE);
ptr_dlg->m_combo.AddString("FIRST");
ptr_dlg->m_combo.AddString("SECOND");
ptr_dlg->m_combo.AddString("THIRD");
}
else
AfxMessageBox("Error creating dlg");
The overridden drawitem method:
void CCustomComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
ASSERT(lpDrawItemStruct->CtlType == ODT_COMBOBOX);
LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData;
ASSERT(lpszText != NULL);
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
ASSERT(lpDrawItemStruct->hwndItem = CWnd::GetSafeHwnd());
// Save these value to restore them when done drawing.
COLORREF crOldTextColor = dc.GetTextColor();
COLORREF crOldBkColor = dc.GetBkColor();
// If this item is selected, set the background color
// and the text color to appropriate values. Erase
// the rect by filling it with the background color.
CBrush br(RGB(255, 0, 0));
if ((lpDrawItemStruct->itemAction | ODA_SELECT) &&
(lpDrawItemStruct->itemState & ODS_SELECTED))
{
// Sets current cursor item color and selected item color
dc.SetTextColor(RGB(0, 255, 255));
// has no effect
//dc.SetBkColor(RGB(255, 0, 0));
// sets current cursor item background
dc.FillSolidRect(&lpDrawItemStruct->rcItem, RGB(0, 0, 0));
if ((lpDrawItemStruct->itemState | ODS_SELECTED) | (lpDrawItemStruct->itemAction & ODA_SELECT) )
dc.FrameRect(&lpDrawItemStruct->rcItem, &br);
}
else
{
// Sets list opening color and default combobox item color
dc.SetTextColor(RGB(0, 255, 255));
dc.FillSolidRect(&lpDrawItemStruct->rcItem, RGB(0, 0, 0));
}
// Draw the text.
dc.DrawText(
lpszText,
strlen(lpszText),
&lpDrawItemStruct->rcItem,
DT_CENTER|DT_SINGLELINE|DT_VCENTER);
// Reset the background color and the text color back to their
// original values.
dc.SetTextColor(crOldTextColor);
dc.SetBkColor(crOldBkColor);
dc.Detach();
}
Thats all the code I've added to the generated code.
I hope this helps you to figure out the problem...
Thanks,
Gaj
|
|
|
|
|
You need to set type property to DropDown instead of DropList .
Go to resource, combo box properties -->styles-->Type , set it to DropDown .
|
|
|
|
|
Thanks for that Prasad... I tried the option. There are two problems with this approach:
1. It does not paint the combobox with the colors that i chose.
2. The selected text is not displayed back in the combobox edit area even if I set the index in the function mapped to ON_CBN_SELCHANGE message.
Can you suggest something on that?
Thanks,
Gaj
|
|
|
|
|
Maybe you forgot to set a value for your combobox and I think you get a runtime error see examples of combobox(DrawItem) on codeproject
|
|
|
|
|
I've referred articles from there. The examples work on simple dialogs but not in my kind of scenario.
Can you try to recreate the scenario as I've mentioned and then provide me a soln if possible?
Thanks,
Gajendra
|
|
|
|
|
if you get this error on DrawText maybe problem is of lpszText,are you sure its valid?
|
|
|
|
|
Ya it should be because it gives this problem only when I set the combobox property to Drop List rather than Drop down.
I'm not able to find a way to do it as per my requirements
Regards,
Gaj
|
|
|
|