|
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
|
|
|
|
|
Dear all,
Currently i am working in creating a property sheet inside a dialog and i am also working in creating a property sheet inside a property page.
There is no problem in creating such a sheet and property pages inside a dialog.
But the problem comes in positioning the property sheet tab controls in right side of the dailog and in vertical positions and to add some images in tab control.
I have used this code to set icons in the tab controls.But it is not working.
CImageList m_imageTab;
m_imageTab.Create(16,16,0,3,3);
m_imageTab.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
m_imageTab.Add(AfxGetApp()->LoadIcon(IDI_ICON2));
m_imageTab.Add(AfxGetApp()->LoadIcon(IDI_ICON3));
CTabCtrl *pTab = internal_sheet.GetTabControl();
pTab->SetImageList(&m_imageTab);
TC_ITEM tcItem;
tcItem.mask = TCIF_IMAGE;
for(int i = 0; i < 3; i++ )
{
tcItem.iImage = i;
pTab->SetItem( i, &tcItem );
}
// I used this member function to set the tab control vertical and i aslo tried the differnt combination of styles.but in vain
internal_sheet.GetTabControl()->ModifyStyle(0,TCS_VERTICAL);
Please some body help me to short out this problem.
:->
Manjunath S
GESL
Bangalore
|
|
|
|
|
hello,
i use vc++ 6.0 and i have a project, that has properly worked !!
I don't know what i have done(with the operating system or something else),
but suddenly the project wouldn't link ? i can compile it but then the linker gives me
the following fault:
error LNK2001: Nichtaufgeloestes externes Symbol "__declspec(dllimport) public: __thiscall std::_Winit
To your information: i use standard-library from objectspace(hp). i have set the path in the options of vc. when i don't set "ignore all standard library" in project settings, then
all is ok. but this means, that i use microsoft stl. but i want't objectspace stl !
Check this, too: the same project, with the same compiler, with the same settings, same stl work
really well on my laptop !
Perhaps somebody out there who can give me a tip ?
thanx
eddyroth
|
|
|
|
|
Hi,
I am interested in developing a file transfer library for use with C++ applications. I need information on how the "resume" feature in download managers like DAP, star-downloader etc work. I would be grateful if someone could direct me to the relevant windows APIs or to some existing open-source projects addressing this issue.
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF}
|
|
|
|
|
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF} wrote: or to some existing open-source projects addressing this issue
Have you looked at WGet[^] it's what I use at home for any large downloads.
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF} wrote: could direct me to the relevant windows APIs or to
There are a couple of articles here at CP, Pause & Resume at Protocol level. (You can implement it in any language)[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|