|
Hiya,
I've never done this but my approach would be to set up an Observer Pattern - so the main window is the subject, and other windows can become observers. Then, make 'OnMove' an event which is pushed to the observers, which then update their position based upon the new position or size of the parent.
Hope that helps,
Andrew.
|
|
|
|
|
I have to set the OPENFILENAME Flags member to OFN_SHOWHELP (I have to use RegisterWindowMessage(HELPMSGSTRING)too ) to display the Help button of the Open or Save As common dialog box.
Where is the best place to do that ?
In DoPromptFileName of a CDocTemplate derivated class ?
Serrand Patrice
|
|
|
|
|
Hello, the codegurus around the world.;)
CFileDialog dlg (TRUE);
dlg.m_ofn.Flags=
if (dlg.DoModal() == IDOK ) {...}:rolleyes:
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
hi, i like to know how to laod and save bmp files in VC++.
this is causing me a great confusion...
HELP ME
Ehsan
Ehsan Behboudi
|
|
|
|
|
Loading BMPs is quite easy, just call ::LoadImage passing the filename and right flags (details in MSDN).
Saving must be done 'manually' - you have to save the BITMAPFILEHEADER first, then BITMAPINFO, the pallette (optionally) and actual bitmap bits.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
There are classes here, at CodeGuru and at www.paintlib.de that make it easier to load and save bitmaps. PaintLib also loads and saves gif, tiff, png, jpg and I have code here to save tga ( it loads them ), which I'd be happy to send you if you go that route.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
I have created an MDI application. Now in this I want to open only text files. So, before opening a file how can I identify whether a file is text(ASCII) or binary file.
Please help me!
thanks,
Shrini
|
|
|
|
|
umm all files (and data) are actually binary when it comes to it
ascii or whatever is just an interpretation of the data (like jpg or avi etc)
you could look for .txt extensions and hope the users stick to the right use of file extensions or (more robust) you could scan the file for anything outside of the ascii char set range of values (allowing cr \ lf \ etc of course)
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Here I cant go by extension, since they are stored with all sort of extensions. May be I have to read the file a bit before opening, to check for any non ascii (text) file.
Thanks for the tip.
Shrini
|
|
|
|
|
I have never done this, so I can't guarantee it will work, but....
You can use the CStdioFile class to open the file (it will open it whether it is a text file or not). Then
perform CStdioFile::ReadString on the file. According to the documentation it reads only text from the file.
If the function throws an error, you don't have text to read. It won't throw an error if it simply encounters
the end of the file or a carriage return. If, however, it returns a string, then you know you have a
text file.
I hope that helps.
David.
|
|
|
|
|
I'm afraid that there's no easy answer to this. You can just use some heuristic rules to make an 'educated guess', for example:
- if file contains only characters from 0x20 - 0x7f range, it's probably a text file
- if file contains fultiple null (0) bytes, it's a binary file
- if file has EXE/DLL/OCX extension and begins with 'MZ' or 'PE' bytes, it's probably a binary file
etc.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
ok, may be it's impossible to comment without looking at the whole code, but may be there's some guru who could find the problem.
if (flag)
// CRect is given the top left and bottom right coordinates of another rectangular object
invalidateRect(CRect(brickTLX, brickTLY, brickBRX, brickBRY));
else
// CRect is given the coordinates of top left and bottom right corners of square bounding a
// circle (a moving ball in a game)
invalidateRect(CRect(ballTLX, ballTLY, ballBRX, ballBRY));
the logic is: if the ball hits the brick then draw only the brick, for all other cases just draw the ball, but it doesn't work do you see any problem with this? please get me out of here...
imran.
oh sorry, i tried to put a smiley but i'm not sure how it works, so don't worry too much if you see a lot of smilies at all the odd places in my message...
|
|
|
|
|
InvalidateRect has a second parameter, which is a BOOL defaulting to TRUE. If it is true, then the code also erases the background. I'm not sure exactly what is going on for you, but try making it FALSE and see what you get. Otherwise, describe more fully what is happening.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
hmmm, may be i should consider a career change. the problem was at some *other* place, showing its effect over here. it's ok now, Christian. many thanks.
|
|
|
|
|
Hello!
I have inhereit a large VC++ project and have now discovered that alot
of the code isn't used.
Is there someway to list all functions and classes that isn't used?
// Mike
|
|
|
|
|
You should look into making your project browsable.
Look under the tools dropdown and select "Source Browser"
hope this helps.
Willem
|
|
|
|
|
You may be able to find a tool that does that, but I don't know of anything specifically...
The only thing I would know to do, would be to use the find-in-files feature of the IDE and if you have anything with only one or two references, it's probably not used, so you can safely assume it's okay to comment it out. Once you've done that with every class, struct, function, and variable, you can recompile and see what you got wrong...
We'll check back with you if we haven't heard from you by the time Christmas rolls around again...
|
|
|
|
|
The BoundsChecker suite includes a program that does exactly that - you run the program, use all the features and it lists the stuff that was not called.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
You can profile your program in typical runtime scenarios.
Link you project with profile enabled and then,
profile it with the 'function coverage' statistics report.
This will tell you how often a function is used, and eventually
tell you which functions are never used at all.
Cheers.
Maxime.
--
Maxime Labelle
maxime.labelle@freesurf.fr
|
|
|
|
|
You can get some insight by compiling in release mode with .map file output turned on. Examining the .map file will reveal which functions were linked into the final executable. In release mode (with optimizations turned on), linker rejects functions that can't be called b/c there are no calls made.
However, the inline functions will be always missing from .map. Optimizing compiler can also decide to use inlining on functions without 'inline' modifier.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hello,
I have a little problem, i don't know how to create a Array that contains different data type.Is it possible to do this without using "struct".
Thanks for help.
R.G
|
|
|
|
|
Hi
The compiler expects all elements of an array to be of the same type.
But there are several ways to work around, but somehow there's no way around a struct or similar type.
If you work with objects, you should use a common base class for all your different types of objects in your array, then you create an array using this base class.
If you use standard c types, the most conveniant way is probably to work with unions. they are used within structures, and allow you to group members within a structure to be part of a union. per structure you can have several unions. the size of structure is the size of the biggest union.
in other terms, the union is kind of a mask which defines how you look at the bytes that belong to your structure... once your structure is an array of chars, once its a couple of intergers, ... it all depends on the unions you define.
to have some type safety, it is recommended for your case to still have a member in the structure that defines which type of union was used, otherwise you can run in quite some ugly problems.
check out your documentation for further reference.
Regards
Daniel
|
|
|
|
|
If you're speaking of classes, that would be easy to accomplish. Create a base class with either an identifier function like "CMyClass::GetObjectType" that returns an integer ID, or by using the MFC "RUNTIME_CLASS" macro.
If you're speaking of structs, you'll have to store pointers cast to void and in each struct, place an identifier field of some sort.
For basic data types like integers and strings, you can build a _variant_t array and wrap the array with a class with accessor functions that allow the programmer to use regular data types (int, double, CString) to populate the array, while hiding the details of the array (the fact that it's an array of variants).
If you really wanted to get fancy (and make the code more compartmentalized and maintainable), no matter which method you uise, you could wrap the array with an accessor class. That way, all the programmer has to do is request an item of the desired type, and the class could return NULL or a pointer...
Piece of cake.
|
|
|
|
|
Hi,
I am writing a image capturing app which support user select any region on screen, so I
used system mouse hook to track mouse movement (WH_MOUSE). Everything seemed right,
until I found that my hook don't reiceive WM_MOUSEMOVE when mouse cursor go out of
current window while left button keep down.
It is very strange, I've debugged but don't find any thing wrong
In all message handle I return 1 for preventing any window process them.
Thanks a lot for your assistance.
Do Quyet Tien
|
|
|
|
|
Hi,
do you have this line "#define _WIN32_WINNT 0x0400" before including Afxwin.h ?
I found that without it that doesn't work right.
Alex
|
|
|
|