|
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:
|
|
|
|
|
Hey, thanks for the help. I will take a look at both. By the way FYI also take a look at "True Downloader" it's an open-source download manager written in VB 6.0!
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF}
|
|
|
|
|
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF} wrote: written in VB 6.0!
I like VB, but that just seems like an application that's steping out of VBs purview. WGet is Open Source, written C++ and is cross platform. Its a command like application that can set it self to run in the back ground which is very cool...
Good luck with True Downloader, hope it works well for you.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
hi,
i have a dialog box with its Context help property to be true.Wats the use of this property?? can any one expalin in detail about it.
i have created a winhelp file is there any possibility to make use of Context help property to access the winhelp file??
thanx in advance,
zari
|
|
|
|
|
zareee wrote: have a dialog box with its Context help property to be true.Wats the use of this property?? can any one expalin in detail about it.
It add question mark, along with close button on title bar.After that , on clicking any cotrol, it receives WM_HELP message.
|
|
|
|
|
can u give me sample code using WM_HELP message??
zari
|
|
|
|