|
if you want to save the string into a stream:
write the length first, the n the data bytes.
If ANSI/UNICODE might be an issue, either write a "tag" which type is used, or always save as unicode.
So many people long for eternity that don't know what to do on a rainy sunday afternoon. [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
I have some terrible problem
I use following code, but buttons and toolbars sometimes flick. To solve flick's problem with Line/Rectangle/etc. Painting i use m_Context, but this causes another problem ;_(
After of the calling BitBlt function, Buttons and Toolbars repaint.
May be i need to paint buttons to m_Context, but how?
void CMy123Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
CRect button;
m_OK.GetWindowRect(&button);
CRect rect;
m_Frame.GetWindowRect(&rect);
//int Width = rect.Width();
//int Height = rect.Height();
int Width = 1000;
int Height = 1000;
m_Context.BitBlt(0, 0, Width, Height, &m_Context,0,0,WHITENESS);
m_Context.LineTo(300,600);
m_Context.LineTo(0,200);
m_Context.SetTextColor(0);
m_Context.DrawText("SSDSDSDSDJKLHklhljk", CRect(200,200,400,400), NULL);
m_Context.TextOut(500,100,m_str);
dc.BitBlt(0,0, Width, Height, &m_Context,0,0,SRCCOPY);
//CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMy123Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
int CMy123Dlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CDC *Canvas=GetDC();
m_Context.CreateCompatibleDC(Canvas);
m_Bitmap.CreateCompatibleBitmap(Canvas,1000,1000);
m_Context.SelectObject(&m_Bitmap);
ReleaseDC(Canvas);
m_i=1;
SetTimer(1,7,NULL);
return 0;
}
void CMy123Dlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
Invalidate();
m_i++;
itoa(m_i,m_str,10);
CDialog::OnTimer(nIDEvent);
}
BOOL CMy123Dlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
//return CDialog::OnEraseBkgnd(pDC);
return 0;
}
|
|
|
|
|
Hi,
My application (under development !) has just developed a most unusual problem (well,I've never seen it before !) In the debug window of MS Developer Studio (VC++ Ver 4.0),I get the following lines:-
Warning: Uncaught exception in WindowProc (returning 0).
First-chance exception in Dgvcr.exe: 0xE06D7363: Microsoft C++ Exception.
Warning: Uncaught exception in WindowProc (returning 0).
First-chance exception in Dgvcr.exe: 0xE06D7363: Microsoft C++ Exception.
(The last two lines are repeated many times.) The problem only occurs after the app has been running for some time, but I've no idea where the problem starts.
Anybody got any ideas on how I can pin this down ?? Thanks in advance !
Doug
|
|
|
|
|
start the program in the debugger. i think in VC4, you can find an "Exceptions..." item in the debug menu. find "MS C++ Exception" in the list and change it to "Stop Always". the program will break when that exception happens.
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
Hi Chris,
Many thanks for your response.
I have now ascertained that the exception is a ResourceException raised during the construction of a CBrush object. I assume from this that I have inadvertently been dynamical creating resources and not releasing them back to the system (would that be correct ??)
I hope that this is not a stupid question, but is there anyway that I can display/trace resources that have been created (and where in my program) up to the point of the exception ? I'd appreciate any advice/help, as I've had little experience of tackling runtime problems like this.
Many thanks !
Doug
|
|
|
|
|
|
Hiya I am writing a program with SQL and an Access Database. I need to set the lenght of the text field (a column) to 600. Can I do this from my program??
I have tried setting it in the database in the design view but it will only allow a maximum of 255 chars. It would be better to be able to set it from the program.
I am using CDatabase and CRecordset and its an ODBC database..
Thanks
grahamoj.
|
|
|
|
|
grahamoj wrote:
I have tried setting it in the database in the design view but it will only allow a maximum of 255 chars
Thats probably because it can't be any longer. So it won't help you if you did it from your program.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Use a Memo field type; these can be 64,000 characters long. A Memo type doesn't have a Length property, so your code will have to handle the 600 character limit prior to storing the values in the table. Hopefully Access doesn't reserve the entire 64,000 character space for each Memo field - that would get ugly really fast - but the Help info doesn't mention how it is implemented.
It is ok for women not to like sports, so long as they nod in the right places and bring beers at the right times.
Paul Watson, on Sports - 2/10/2003
|
|
|
|
|
Hi grahamoj, text can be maximum of 255, however a memo as others have pointed out will suit and the JET database engine doesn't waste any unused space so no problems there.
In order to create fields or modify them programatically (and in the easiest possible way, there are others) you need to use data definition sql statements:
See here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acfundsql.asp[^]
See also in that article at the bottom the intermediate and advanced articles. That should give you all the info you require.
This is something I have done a *lot* but through ADO, not odbc so I can't give you anything more specific.
|
|
|
|
|
Thanks will check it out.
grahamoj.
|
|
|
|
|
I have created a MDI application.Then I have created to views. One from CView Class and other from CFormView class.When I click on the new in the menu Two windows are created one with CView and other with CFormView through OpenDocumentFile().I have also created two Document templates but both are having same CDocument class. Now I want that when i do something in the CView(Click etc..) one of the functions of the CFormView should be invoked.i.e when clicking in the CView i want to send message to the other CFormView and vice versa ?
How can i ?
manoj Kumar Dalei,
IIT Delhi
|
|
|
|
|
If the views belong to the same DocTemplate, get the CDocument pointer of one view and call UpdateAllViews method. Use the hint parameters to let the receiving view know to whom the update is for.
|
|
|
|
|
One solution is to call a functio in main frame and have it route the data to whatever view accordly.
Kuphryn
|
|
|
|
|
It might not be a good solution. If you do not like architecture of MFC(as many of us) - do not use it. There is very well defined way for view notifications in MFC (UpdateAllViews). Custom solution like this increase maintenance problems.
|
|
|
|
|
Correct. Nonetheless, there are situations where custom routing in an MFC application is key. One situation is updating a selected view or object within a selected view.
Kuphryn
|
|
|
|
|
How to Rotate the Enhanced MetaFile without using SetWorldTransform?
|
|
|
|
|
we have a single program, very large, so far, pure h/c++ code is over 6M. as customers request, the program is still expanding ...
it works fine now. i am not sure but i do worry about that someday the program will crash because of its size.
do u know if there is limited program size for a single application - if over the size, it can't be executed?
thx
includeh10
|
|
|
|
|
includeh10 wrote:
do u know if there is limited program size for a single application - if over the size, it can't be executed
Naaa, I don't think you'll ever reach a limit. As long as there's enough ram in the clients computers
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
No, it shouldn't crash at any time just because the executable is large. If you worry about the size you could put the most important code of you exe into seperate DLLs. Guess how complex programs do that: E.g. the executable of UnrealTournament 2003 is only about 900kbyte. Can you imagine how large it were if all the code of the DLLs would be inside the executable?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
includeh10 wrote:
do u know if there is limited program size for a single application
Yes, 2GB. That's the max amount of memory a user-mode process can occupy in Win32 (on 2K adv server you can make that 3GB with a switch in boot.ini).
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Can you imagine the amount of source code required to create a 2GB executable? It would have to be a very complex app, or one with a lot of constant data, or both.
Not to mention the days/weeks required to compile the sucker...
Software Zen: delete this;
|
|
|
|
|
Hello
In my project I need some way to show text with pictures, font colors and tables in two columns on each page, but with ability to set no-column mode. It should look like MSWord pages view.
If anyone knows of such a view class or the way to make CRichEditView show columns and page breaks or even some thoughts from where to start searching, please, answer me here or e-mail to archigal@mail.ru.
Thank you in advance
|
|
|
|
|
I'm not sure whether CRichEditCtrl can display a word document with tables in it. What format is your data in?
In all honesty, it sounds like this is a job for an HTML view rather than a rich edit. I find CRichEditCtrl a pain, but CHtmlView is a lot easier to drive.
Also, MFC 7 has an HTML edit control which you might want to take a look at if you need to enter data.
Anna
www.annasplace.me.uk
"Be yourself - not what others think you should be" - Marcia Graesch
Trouble with resource IDs? Try the Resource ID Organiser Add-In for Visual C++
|
|
|
|
|
hi, anna,
i still use VC 6, did u try if html edit control (VC 7) can load java JApplet object?
(sorry, not for original post)
includeh10
|
|
|
|