|
Hello,
I'm new to this programming stuff and am having a problem with a SDI. I have created a program to append multiple text files into one. Everything works great except I can’t seem to display the text when I open a text file. I can open the text file and store the text from that file into a CString member variable. When I keep opening files my program keeps adding the text to the same member variable.. Then when I chose to write the contents of the variable to a text file every thing works fine.. This all works great but when I open the files and store them into the variable I don’t see the text on the screen in my program.. Like I said I'm new to this and its probably something dumb..
Any help would be appreciated..
THANKS!
Rob Jones
|
|
|
|
|
The point of the view is that you're able to manage how your data is displayed - nothing happens by itself in that regard. Drawing is done in OnDraw, or OnPaint. Whatever you output to the DC created in OnPaint ( or passed to OnDraw from OnPrepareDC ) is what you will see. Look up CDC::ExtTextOut for info on how to output text.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
hi,
this is the deal.
I have a SDI application. and a sub-menu,,
when the user clicks on the sub-menu, the left click of the mouse should be activated for only one click.
thats all..
How can i do that. I'm able to activate the LBUTTON in the CView,
but i don't know how to do that right after the sub-menu is clicks.
I really appriciate your feedback.
ehsan
Ehsan Behboudi
|
|
|
|
|
I'm Sorry, but I don't understand what happens.
You can be clearer???
Cheers!!!
Carlos Antollini.
|
|
|
|
|
do you mean "how do i disable the menu item after it is clicked once" or "how do i set the focus to the right view after i click on a left-view sub-menu item" ... or something altogether different?
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I'm making a dialog box - based application, and I want list boxes. I've generated a list box in the resource editor, and I want the simplest possible explanation of how to add and retrieve elements from/to it.
The MSDN lib didn't help me here at all.
I know there is a list box tutorial on this (excellent) site which starts out (too) "basic", but then skips the "how do I add or remove elements" part and jumps right onto periphere subjects such as "how to change list styles at runtime" and similar.
Not very useful, sorry..
I would really appreciate someone's help on this basic subject.
greetings,
Gustav Tresselt
= Gustav =
|
|
|
|
|
1) open your Visual C++ help/MSDN
2) select 'Index' tab
3) type CListBox
4) select 'class members'
One of the method is described as one that 'Adds a string to a list box'. Another 'Copies a list-box item into a buffer'. I'm leaving finding method names as an exercise
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks for a *very* quick reply! However,
the real problem is simple, but not that simple.
Here's what I added (to complement my listbox IDC_LIST1
from the Resource Ed)
My *Dlg.h-file; 'class CDekodLog : [..blabla..]',
--
Added: CListBox lst;
In the *Dlg.cpp-file: 'OnInitDialog':
--
Added: CRect rc; GetWindowRect(&rc); ScreenToClient(&rc);
lst.Create(WS_CHILD|WS_VSCROLL, rc, this, IDC_LIST1);
CString stri = "Per pusling";
lst.AddString(stri);
UpdateData(FALSE);
So far, so good? FINALLY; the DoDataExchange-routine;
--
Added: DDX_Control(pDX, IDC_LIST1, lst);
^^ This is my attempt to transfer the test-data stored in
the lst-object to the IDC_LIST1
(snipped from the ListBox-tutorial-source from this domain).
This results in:
a) Debug assertion failure, and
b) a fatal error which shuts down my app..
Thx again,
Gustav
= Gustav =
|
|
|
|
|
DDX_Control inside DoDataExchange assigns your 'lst' member variable to already existing Windows listbox control. You don't need to call lst.Create. Creation occurs before your code is executed. DoDataExchange is called from CDialog::OnInitDialog. Your calls to CListBox::AddString must be placed *after* CDialog::OnInitDialog, because the 'lst' variable has to be properly initialized by DDX_Control. One more thing - UpdateData(FALSE) is also unnecessary.
Generally speaking, you can do anything you want with your CListBox, but after CDialog::OnInitDialog. Adding and removing strings doesn't require calling UpdateData.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks for another *very* swift reply!!
Now my source works, and I am [lim inf] grateful!
Quick sum-up of conclusions:
* Declare a CListBox-object somewhere
* Use the "DDX_Control" in DoDataExchange to initialize it
* Add/remove strings and it will be updated by the DDX_Control
each time you UpdateData()..
That really helped.. thanks again!
= Gustav =
|
|
|
|
|
One thing to remember: adding/removing strings does not require UpdateData. CListBox::AddString (as well as almost all other members of CListBox class) is just a thin wrapper around Windows message LB_ADDSTRING - your string will appear instantly on the screen.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hello, the codegurus around the world.;)
To be sure, class wizard is a useful tool to decrease the developement time.
However, UpdateData(FALSE) tries to update all data which belongs to DDX function.
So, if we don't do this, not use UpdateData function.
Besides, GetDlgItem(ID NUMBER) also gets CWnd of each control, sometimes we don't need
to use class wizard at all.
As we write the code so much in VC++, we understand which cases we should use the class wizard or use just GetDlgItem().
At the beginner level, I think that he or she had better use GetDlgItem to understand how
we do the cast of each control CWnd and the other suffs.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Casting the return of GetDlgItem is a *bad* idea if you have the option of setting up a member variable that is of the correct type to start with. I would recommend that anyone using VC++ learn how to insert message handlers/variables without using the class wizard, because eventually you'll need to know how it is done, but once you know how to do it, there is no reason not to let the Class Wizard do the donkey work for you, in the same way that I believe anyone should write their own string class/array class/linked list class, but should still use CString/vector/list at the end of the day for most applications.
It can also be useful to call UpdateData without ever calling UpdataData(false), when we want to know values, for example this is how the radio button groups work, but do not want to change anything that needs to be sent back 'up the line'.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
Hi all,
this may be a stupid mistake, but i got the following when using TransparentBlt:
error LNK2001: unresolved external symbol __imp__TransparentBlt@44
I tried including windows.h, wingdi.h, and using gdi32.lib (and combination of them).
Can anyone point out my stupidity?
|
|
|
|
|
You should link your project with Msimg32.lib.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
Thank you very much.
|
|
|
|
|
After adding the decoding files of the eldos sound engine, i get following error :
fatal error C1010 : Unsuspected (or something End of file while seeking the directive for the precompiled header
and if i click on it i get to the end of the file ( } ).
What causes this error ? How can i fix it. I saw it work in another project but i dont know how to fix, so please help me.
|
|
|
|
|
Add this line into added .cpp files
/#include "stdafx.h"
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
Thank you so much !!!
now it works just perfectly.
|
|
|
|
|
While including stxafx works, I prefer to set the project to automatic inclusion of standard headers, so that anything that doesn't include stdafx will still compile without it.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
Hi, I have a three-way splitter window defined like this in my SDI application:
if (!m_wndSplitter1.CreateStatic (this, 1, 2) || !m_wndSplitter1.CreateView (0, 0,
RUNTIME_CLASS (CScrollView), CSize (dataviewwidth, 0 ), pContext) ||
!m_wndSplitter2.CreateStatic (&m_wndSplitter1, 2, 1,
WS_CHILD | WS_VISIBLE, m_wndSplitter1.IdFromRowCol (0, 1)) ||
!m_wndSplitter2.CreateView (0, 0,
RUNTIME_CLASS (CGraphView), CSize (0, graphviewheight), pContext) ||
!m_wndSplitter2.CreateView (1, 0,
RUNTIME_CLASS (COutputView), CSize (1, 0), pContext))
return FALSE;
That is with two different views (CGraphView, COutputView) in the second splitter window. I try to add serialization
to my software but when I try the New or open command the app is crashing.
When myDocument::OnNewDocument is invoked i get an assertion error in the function
void AFXAPI AfxHookWindowCreate(CWnd* pWnd) (ASSERT(pWnd->m_hWnd == NULL); )
This is does not occur when the document is created at start. If I have the same views in the second
splitter window there is no problem. Also if I destroy the second view in the second splitter window with
pView->DestroyWindow() in the myDocument::Serialize(CArchive& ar) function I can Invoke the save command
without crashes (although the destroyed view might lock). It seems like there is a problem updating the second
view if it already has been created.
Does anyone have an idea how to solve this problem I would be more than happy!
/Ingemar
|
|
|
|
|
So the code that calls CSplitterWnd::CreateStatic is in OnNewDocument?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
No, I was a little unclear in my description of the problem. I have the code for the splitter windows in
CMainFrame::OnCreateClient. When I try to reuse the document (new or open document command) it cant
recreate the splitter windows and the app crashes. It seems like a function InitialUpdateFrame is not working
then. I hope this made it clearer.
/Ingemar
|
|
|
|
|
It seems that your OnNewDocument method creates some windows. An object of CWnd-derived class can be mapped to zero or one HWND. The ASSERT you're experiencing is caused by calling CWnd::Create[Ex] (the call may be indirect) on CWnd-derived object that already is a legitimate window.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I solved the problem. I had a pushbutton in one of my views that wasn't destroyd with it. This caused the crash.
/Ingemar
|
|
|
|