|
"Send you a good example" that would be brilliant. Thanks for the advice too. I do have some added info which completes this, officially, as THE strangest problem ever. If I write the code
MessageBox(GetActiveWindow(), "Whatever", "Whatever", MB_OK) before I do any page flipping, the code works and I see this beautifully changing but crappy animation. Take it out and I get picture, blank, picture, blank etc. How stupid and strange is that! I mean what has messagebox got to do with anything? Also I notice that the primary surface always gets refreshed at application startup(made blank), whilst the back buffer retains the image that was in memory last (even if the application NEVER draws to it/clear it or anything). I take it this is normal? Many Thanks anyway Rage,
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Alan Chambers wrote:
I mean what has messagebox got to do with anything
Well, if you are running DDraw windowed, you have to define clipping regions. Anyway, mixing GDI (i.e. messageBoxes) with DDraw is not trivial, so I suppose it is not anormal that sometimes strange things come out
~RaGE();
|
|
|
|
|
I have a set of classes all derived from a single abstract base class (not CObject-based). Each of these classes can serialize itself, and does so by first calling Serialize on the base class, to serialize the common stuff.
Now, i'm adding clipboard support for these objects. I used the "clipboard assistant", which is uses CArchive to store the objects. Storing them on the clipboard is easy, just serialize out. So far so good. But going the other way, creating an object based on data from the clipboard, is where I'm stuck. I can't just serialize to my derived objects because I don't know which one to use - all I know is that I have a chunk of serialized data that came from one of my derived classes. I can't serialize to the base class because it's abstract.
Part of what the base class serializes is a tag that identifies the derived class type. But, I can't read into that CArchive to find the tag, then rewind, because CArchive doesn't have any "rewind" functionality (though its CFile member probably does).
Any ideas?
-c
Garbage collection, making life better - for weenies!
|
|
|
|
|
Not like you to be posting questions Chris, you normally answer mine. I'm a little shakey answering this cos I'm not really sure if its what your after, but it may at least give you an idea. Have you tried using fstream to read in the first struct/value of your file and based on that use a case statement to process the correct CArchive and serialize routine? I'm not that clued up about MFC but I think your in a bit of a catch 22. If I'm on the right lines, I'd be happy to help a bt further.
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Alan Chambers wrote:
Not like you to be posting questions Chris,
yeah, there are some things i just never do much of - this is one of them.
looks like i'll end up doing something like what you're describing. i was hoping for a cleaner way. oh well.
-c
Garbage collection, making life better - for weenies!
|
|
|
|
|
Chris, see my 3rd serialization article, specifically the section "Serializing a heterogenous collection class". I have sample code that uses the factory pattern to implement this. Send me mail if you'd like me to send it to you (virtual NDA assumed ).
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I am writing a simple program which makes calls of a DLL. My program crashes shortly after making a call to any function of the DLL, even when the function doesnt do anything and returns void. My memory manager gives me a message about operator delete, suggesting that some memory has been messed up somewhere. Initially, the function call appears to be succesful, it just crashes as i step through amongst some dissasembly code.
Thanks in advance
James
|
|
|
|
|
Sounds like a mismatched calling convention. For example, the DLL routines are using __stdcall while the caller thinks the routines are all _cdecl. This causes all sorts of nasty stack thrashing.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Think I found a Bug in the API Function TabbedTextOut. When Parameter nCount is 1 and nTabOrigin is 80 and lpnTabStopPositions is 67 (pointer to int with value 67) the Function behaves like nTabOrigin is 0. nTabOrigin can be only 13 greater than the int-value lpnTabStopPositions points to. With an array with more than one value the Origin parameter works well.
Can someone report this bug to MS?
|
|
|
|
|
Hello,
I need to know how to create a new child MDI window. I have a program that opens bitmap images, but it doesn't put them on a new window. I want to know how to write my own OnFileNew command basically. Mayeb my problem is with my fileOpen, since it doesn't open new windows?
If anyone has any advice on how do this, or even better, KNOWS how to do this, I would be very happy.
thanks a lot
NickOne
|
|
|
|
|
Look at the code in the OnFileNew handler. It does what you want,just copy the relevant bits.
|
|
|
|
|
Hi people,
I've just set up some scrollbars with the guidance of a nice cp article, but there's a small thing I'd like to change:
The code makes the scrollbar disappear when it's no longer needed.
However, some apps (like Notepad) always show the scrollbar and just hide the thumb instead.
Anyone know how to do that?
Thanks,
Ren
|
|
|
|
|
EnableScrollBar(SomeHwnd, SB_VERT, ESB_DISABLE_BOTH);
does the trick with the vertical scrollbar...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi,
Thanks for the help. Your code solved the problem, but I found another approach as well.
Here's my OnSize handler:
void COverviewWnd::OnSize(UINT nType, int cx, int cy)
{
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_PAGE|SIF_RANGE|SIF_DISABLENOSCROLL;
si.nPage = cy;
si.nMax = rctTotal.Height();
si.nMin = 0;
SetScrollInfo(SB_VERT, &si);
CWnd::OnSize(nType, cx, cy);
}
Apparently SetScrollInfo automatically calculates whether the scrollbar is necessary or not by comparing nPage (the available space) and nMax (the total space the document occupies).
It's default behavior is to hide the scrollbar when it's no longer needed, but you can set the SIF_DISABLENOSCROLL flag to have it disabled instead.
You probably knew this, but I wrote it down anyway for those who don't.
Greetings,
Ren
|
|
|
|
|
I know this is a really stupid question, but I'm use to programming on Unix systems.
I wrote a program using MS Visual C++, and I want to pass in a value into the argsv.
so I can run it at the command prompt something like: "whatever.exe filename.txt"
of course this doesn't work. Any ideas?
ICXC
NIKA
|
|
|
|
|
Why doesn't it work, I have done that lots of times...
Starting a program with "whatever.exe filename.txt" from the command promt I mean, and it works just fine.
What exactly are you trying to do that don't work?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
It works when I use the ms-dos command prompt. when I just go to start and run, then browse, then try to do it, it's a no go.
ICXC
NIKA
|
|
|
|
|
You have to write "someprogram.exe" somefile.txt instead of "someprogram.exe somefile.txt"
Then it works
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I'm not sure whether this is what you're after, but in a Windows-based app you can use the variables __argc and __argv just as you did with the usual main parms in an Unix console program.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
WinMain(), as you've seen, doesn't have the argc/argv params. You can access them via the lpCmdLine parameter to WinMain(). Alternatively, there are __argc and __argv variables that the CRT sets up for you that work like argc/argv.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
hi!
I wish, in my program to send Message via
"SendMessage" to the "NotePad".
For a start, I want to send a WM_KEYDOWN
to write a letter in notePad's writable area.
I have the handle of the notePad.
if any one can assist me, I would be very
very thankful.
Eynat
"things can only get better!"
|
|
|
|
|
Try it.
You will probably have to send a WM_CHAR as well.
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
|
Thank you for your help.
what I really need to do is:
I need to, from without the note pad, close a modal messageBox.
modal - messageBox is reffered to the messagebox you get once you try to exit the notepad and you're asked if you wanna save the changes .
this msgbox I need to eliminate , I assume, with a message from an outer application.
If anyone has an idea or has done such a thing before - I would be glad/relieved to know - for this is part of a very urgent assinment I have to accomplish.
Thank you (again) ,Eynat
"Things can only get better"
|
|
|
|
|
Yes, you can use this trick to do that.
You'll find 2 windows in notepad - the main frame window (whose handle you can FindWindow based on the caption - e.g. "Untitled - Notepad") - and its child, which is an edit box.
To type text into notepad, post the key stuff to the edit box.
To send a key that will close the messagebox (Y, N, ESC), send it to the main window.
|
|
|
|