|
Jun Du wrote: 1) Your app overrides OpenDocumentFile() so that it displays any views beside the default.
Yes, this is done. When I open an existing document (and ONLY then), both views appear and work correctly. It is done this way (just like the sample):
CDocument* CSequApp::OpenDocumentFile(LPCTSTR lpszFileName) <br />
{<br />
CSequDoc* pDoc = (CSequDoc*) CWinApp::OpenDocumentFile(lpszFileName);<br />
if (pDoc == NULL)<br />
return NULL;<br />
CFrameWnd* pNewFrame = m_pEditorTemplate->CreateNewFrame(pDoc, NULL);<br />
if (pNewFrame == NULL)<br />
return pDoc;<br />
m_pEditorTemplate->InitialUpdateFrame(pNewFrame, pDoc);<br />
}
Jun Du wrote: 2) Let your app to handle file-new command, and call the overriden OpenDocumentFile() in the command handler.
At present, I have this in the message map:
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
If I understand you correctly, I should change it to...
ON_COMMAND(ID_FILE_NEW, OnFileNew)
...and then define the OnFileNew function:
void CSequApp::OnFileNew()<br />
{<br />
CWinApp::OnFileNew();<br />
... (some call to OpenDocumentFile())<br />
}
Is this right? In that case, what's the code I have to add there? I don't think I'll get it right myself...
|
|
|
|
|
requemao wrote: If I understand you correctly, I should change it to...
ON_COMMAND(ID_FILE_NEW, OnFileNew)
...and then define the OnFileNew function:
void CSequApp::OnFileNew()
{
CWinApp::OnFileNew();
... (some call to OpenDocumentFile())
}
Yes.
Best,
Jun
|
|
|
|
|
Check out this technical article [^]; it describes how OnFileNew() should be overridden. Basically, in case of multiple document templates, don't call base class'
CWinApp::OnFileNew();
in CSequApp::OnFileNew(). Add code to retrieve the file name first and then call
OpenDocumentFile(fileName);
The resulting code should be similar to CHKBOOK sample code.
Best,
Jun
|
|
|
|
|
Jun Du wrote: in CSequApp::OnFileNew(). Add code to retrieve the file name first and then call
OpenDocumentFile(fileName);
I must be overlooking something. Even after reading the whole tech note and browsing trough the member functions of CDocument and CWinApp, I still haven't found out how to retrieve the file name (which is required by the OpenDocumentFile() function). Can you please point me to the function I need?
Manuel M.
|
|
|
|
|
The relevant part from the article is:
"One common customization of ID_FILE_NEW is to provide a different and more graphical choice of document types. In this case you can implement your own CMyApp::OnFileNew and place it in your message map instead of CWinApp::OnFileNew. There is no need to call the base class implementation."
Maybe this is where you find confusing:
The base class OnFileNew() doesn't ask for the file name, because it automatically creates one ("New") for you. However, it only displays one view. Without overriding OnFileNew(), you won't get more than one view at the startup. You have to override OnFileNew() and call OpenDocumentFile(), which requires a file name and the file must be created before the call.
After reviewing the CHKBOOK sample code carefully, you'll find its OnFileNew() does only two things:
1) Prompt a GUI to ask for the new file name and create the file.
2) Call the overridden OpenDocumentFile() with the file name.
It didn't call base class' OnFileNew(), which I think you know why now.
So, the code before calling OpenDocumentFile() should be:
1) Constructing a file name (either asking the user or use "New" as the default).
2) Creating that file physically on the current folder.
Note that this is how CHKBOOK is implemented and it looks like what we have to do if we use OpenDocumentFile().
Best,
Jun
|
|
|
|
|
It now works, thanks to you!
I appreciate the effort you have put in explaining this to me and giving me accurate pointers. You have taught me quite something, thank you very much.
Manuel M.
|
|
|
|
|
You're welcome. Glad it worked out finally.
Best,
Jun
|
|
|
|
|
Does anybody know if there is an option for non-grid fitting ClearType Font rendering in GDI+ ?
I use the AntiAlias FontRenderingHint currently which yields fairly stable string widths at various scales but the readability suffers a tad (blurry) so I wanted to see if ClearType would help, but I can only find a grid fit for cleartype in the enumeration which suffers the same width/height issues as GDI fonts at various scales due to hinting/rounding errors etc...
I would guess non grid fit rendering would be possible with subpixel rendering but it seems to not be a reality for GDI+
Any ideas on whether this is even possible and where one might find it if it were?
|
|
|
|
|
I'm trying to pass a struct by reference to a callback function, but I cannot for the life of me deference it. Here is the initialization and sending of the struct
WINDOW_SKIN ws;
ws.iSize = sizeof(WINDOW_SKIN);
...
hWnd = CreateWindow( WINDOWBITMAP_CLASS,
...
hInstance,
&ws );
Just as you would do with any other struct. But on the recieving end:
WINDOW_SKIN *ws = (WINDOW_SKIN*)lparam;
if ( ws->iSize == sizeof(WINDOW_SKIN) )
The ws pointer holds the address of lparam , and the iSize paramater holds the address of the struct. I know lparam is a pointer to a an address, but how can I get to my data?
|
|
|
|
|
Never mind, after trying several gazzillion variations I found it.
WINDOW_SKIN *ws = *(WINDOW_SKIN**)lparam;
|
|
|
|
|
The only reason that works, and not (WINDOW_SKIN*) is that you didn't pass a WINDOW_SKIN* , but a WINDOW_SKIN** - or you're incredibly lucky. Have you looked at what you pass to CreateWindow and what you receive in your WM_CREATE handler (I'm assuming it's WM_CREATE ), using the debugger?
--
Torn from tomorrow's headlines
|
|
|
|
|
I've got two HEX values: 0x4D and 0x5A
I want to combine them (not add them together), so that I have an unsigned short variable with the value 0x4D5A (= 19802).
How can I accomplish this?
To be a little bit more specific:
1. I've got a temp array (unsigned char tmp[1]; ) where each byte in a binary stream passes through.
tmp[0] = br->ReadByte();<br />
tmp[1] = br->ReadByte();
2. I've made a struct like this:
<br />
struct EXE {<br />
unsigned short signature;<br />
unsigned short bytes_in_last_block;<br />
unsigned short blocks_in_file;<br />
unsigned short num_relocs;<br />
unsigned short header_paragraphs;<br />
unsigned short min_extra_paragraphs;<br />
unsigned short max_extra_paragraphs;<br />
unsigned short ss;<br />
unsigned short sp;<br />
unsigned short checksum;<br />
unsigned short ip;<br />
unsigned short cs;<br />
unsigned short reloc_table_offset;<br />
unsigned short overlay_number;<br />
void dbgPrintToConsole()<br />
{<br />
Console::WriteLine(L"Signature - HEX : 0x{0:X}", signature);<br />
Console::WriteLine(L"Bytes in last block : {0}", bytes_in_last_block);<br />
Console::WriteLine(L"Number of blocks in file : {0}", blocks_in_file);<br />
Console::WriteLine(L"Number of Relocations : {0}", num_relocs);<br />
Console::WriteLine(L"Header Paragraphs : {0}", header_paragraphs);<br />
Console::WriteLine(L"Minimum Extra Paragraphs : {0}", min_extra_paragraphs);<br />
Console::WriteLine(L"Maximum Extra Paragraphs : {0}", max_extra_paragraphs);<br />
Console::WriteLine(L"SS register start-value : {0:X}", ss);<br />
Console::WriteLine(L"SP register start-value : {0:X}", sp);<br />
Console::WriteLine(L"Checksum (usually not used): {0:X}", checksum);<br />
Console::WriteLine(L"IP register start-value : {0:X}", ip);<br />
Console::WriteLine(L"CS register start-value : {0:X}", cs);<br />
Console::WriteLine(L"Relocation table offset : {0:X}", reloc_table_offset);<br />
Console::WriteLine(L"Overlay Number : {0}", overlay_number);<br />
}<br />
};<br />
So what I'd like to do, is to assign every two bytes into the unsigned short variables in the struct EXE.
I should probably mention that I am a VC++ newbee.
Hope this makes sense to someone?
Cheers,
TylerD75
|
|
|
|
|
Use the bitwise shift operators
short x = 0;
x = 0x5A;
x ^= 0x4D << 8;
|
|
|
|
|
Hey thanks m8!
That worked too!
I'll implement a method in struct EXE, with a switch, so your way is A LOT simpler!
Thanks again!
Cheers,
TylerD
|
|
|
|
|
no problem. It can be done in one line, but I simplified for you.
|
|
|
|
|
Never mind! I figured out how to do it with memcpy
Cheers,
TylerD75
|
|
|
|
|
Okay. I admit my deep, dark secret. I'm a Delphi programmer - with a bit of Visual Basic thrown in from various jobs. But I'm looking at a program I'd like to get running under Windows but it's a Linux application and it uses either the Qt or GTK+ libraries. The app is FBReader, an ebook reader, and the author made it open source; it is written in C++. But I don't know diddly about using Visual C++ or VC++ Express. Could someone tell me how to make the GTK+ library available to VC++ Express?
Derek Benner
|
|
|
|
|
First of all, prepare for a big learning curve. GTK is NOTHING like Delphi, so be prepared for this.
Secondly there are a few things you'll need to adjust for Win32 development in VC Express.
As you know the download is here:
http://msdn.microsoft.com/vstudio/express/visualc/download/[^]
However, you'll almost certainly need a copy of the Platform SDK (which is NOT included with the free edition, but is required for general Win32 development). That's here:
Platform SDK[^]
Finally, and this is crucial for getting the IDE to properly compile and link stuff that doesn't use .Net, you'll need to tweak some settings:
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/[^]
Once all that's done (and it's a one time thing) you can try and install the GTK stuff.
For the windows version, check out:
http://www.gimp.org/~tml/gimp/win32/downloads.html[^]
However, please be aware that there are no IDE project files in the source (at least in the files I looked at). If you want these you will have to look at the makefiles (check out the make files with the .msc extension), and create them from hand. Note that the actual source is the .bz2 version of the various files. If you are using VC Express, you can't use the pre-compiled GTK versions that Tor provides because these are built with VC6 and link to the VC6 C Runtime, and I don't think you can mix and match C Runtime version between VC6 and VC Express. So you'll almost certainly need to build all the libraries from code yourself (welcome to the world of OSS , sigh... ).
You might try visiting the GTK mailing lists, people may have links to more stuff and/or docs for VC Express.
Good luck.
Also, not to pimp my own stuff, but if you're looking for something more Delphi like, in C++, you might check out the VCF[^]. It's a C++ project I work on, and being a huge former fan of Delphi, I went out of my way to make it Delphi like in a number of different areas.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Do you think the VCF supports enough widgets for me to create a Windows 'clone' of FBReader? And is there enough code to port this reader back to Linux? Also, how large is the footprint of VCF? Eventually, we want to create an embedded application that runs under uCLinux on a PXA270 or ARM7/9 board, if necessary with Nano-X to handle the low-level display driver (based around an e-ink 6" display). Given the nature of the project and the need to support USB ports, SD card slot, Nano-X and display of ebooks, would VCF fit within a 32MB/64MB embedded Linux system - it's a given that uCLinux on this system is less than 4MB and Nano-X is about 1.5MB.
Derek
|
|
|
|
|
hi, i am working on a tool (c++ mfc) that needs to copy a folder, then delete a folder.
This is terms of copy the entire folder, then delete.
Example, C:\CopyMe to C:\CopyMeHere, then delete C:\CopyMe .
is there any simple functions for that?
thanks,
Fred
|
|
|
|
|
|
thanks, will give it a try.
Fred
|
|
|
|
|
...and also see MoveFile(...)
|
|
|
|
|
Hello,
I'm using Visual C++ 2003.
I have a problem in my code at line 36,you can see the code here(I give you all the code of the file because I think that all the things are important):Code[^]
T1 is an Tic_Tac_Toe object (the class is defined from line 5-14.
pointersToNodes is a pointers array to Tic_Tac_Toe objects.
and buildNewTree is a function which returns adress of a Tic_Tac_Toe object(line 78).
at line 36 it writes me the following error:
<br />
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Tic_Tac_Toe *' (or there is no acceptable conversion)<br />
Thats it.
Can you please tell me please why the error occurs and how to solve/fix it?
Thank you all!
SnaidiS(Semion)
|
|
|
|
|
Your declaration of the array is the problem.
Tic_Tac_Toe *PointersToNodes;
...
PointersToNodes=new Tic_Tac_Toe[9];
It is not an array of pointers, but an array of objects. For each Tic_Tac_Toe, you are calling the constructor.
try this
Tic_Tac_Toe **PointersToNodes;
...
PointersToNodes=new Tic_Tac_Toe* [9];
|
|
|
|
|