|
Hi everyone,
First let me confess that I am a VC++ dummy.
I am stuck up in a project where i want to display the text / graphics in a window and require to implement to the scrolling (a CWND BASED CLASS and NOT A CVIEW BASED CLASS, we are not using a Doc-View architecture ).
Can anyone illustrate the code with explanation? OR Can anyone direct me to a good tutorial on scrolling the content in a window?
Mangesh
|
|
|
|
|
Universe Technology is just starting out and is looking for programmers. If you have skill in ASP, VBSCRIPT, HTML, Java, JavaScript, C++, C, XML or any other programming language of substance, please send me an e-mail at Alexjfink@aol.com, I will look into each applicant personally, if we like what we see, we will tell you more about Universe Technology.
|
|
|
|
|
Alex J Fink ? Is this an elaborate hoax ? You can program anything you like for these people ? Sounds like they have no idea what they are going to be creating...
P.S. If you're in Australia, have lots of money behind you and are paying top dollar, then someone else wrote this in my name, please contact me for my resume...
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.
|
|
|
|
|
Any relation to http://www.utechnology.com/ ?
Michael
|
|
|
|
|
They're a consultant company like Robert Half, Inc, or Maxim Group.
I'm not real fond of places like this because of something I'm experiencing right now. I recently relocated from San Diego to San Antonio based partially on Maxim Group's claim that there were "lots of C++ jobs in San Antonio" and that I should "never have a problem staying employed as a C++ programmer". Well, here I sit, and there's not a SINGLE C++ job available in this town - and I've been looking since November.
Take EVERYTHING they say with a HUGE grain of salt.
|
|
|
|
|
Well i made a small dialog based app which calculates x values of the equatation ax2 + bx + c = 0. I made 5 edit boxes 3 for a, b, c values and 2 read-only ones for x values and one button to calculate. I also removed IDOK and IDCANCEL buttons (i don't want users to exit that way,
the only way i want them to exit is to click on the 'x' up in the corner of the title bar). But now if user inserts values and pushes enter, when the calculate button isn't highlighted(i don't know how to call that, may-be you call it something else...), then well the program closes, and i don't like that. Anyhow i'd like to make it so, whenever the user presses enter, the calculations are made, instead of closing the whole bloody thing. I've tried adding enter key to accelerators and call the same function as the calculate button has, but well, it didn't work...
So could someone enlighten me a bit about the subject, please
I'm a real newbie and desperately need your help.
---Thy humble servant Filosofem
|
|
|
|
|
1) Dialog box applications don't have support for accelerators.... at least not by default. You can patch it in like most things, but it can be a chore.
2) A dialog based app handles OnCancel (ESC) and OnOK (Enter) whether you use the button or not. If you want to disable the Enter key from calling OnOK (or ESC). Simply do this:
class CMyDialog : public CDialog
{
...
... (etc)
...
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CMyDialog)
virtual BOOL OnInitDialog();
DECLARE_EVENTSINK_MAP()
//}}AFX_MSG
virtual void OnOK() {}; // Must be overriden to keep ENTER key from exiting out of dialog
virtual void OnCancel(){}; // Must be overriden to keep ESC key from exiting out of dialog
DECLARE_MESSAGE_MAP()
...
...
...
};
|
|
|
|
|
|
Add into the class the Message handler:
PreTranslateMessage(MSG* pMsg)
{
}
and add the following code init.
if (pMsg->wParam == VK_RETURN)
return 0;
return CDialog::PreTranslateMessage(pMsg);
Shahzad Ahmad...
|
|
|
|
|
Hi. My Problem is the following : I have two dialog windows, one main window and another one. I want to do the following: when i move the main window, the second window should move too (snapped to the right side of the main dialog.). Imagine the situation in Winamp. The equalizer moves , when you move the main window. So my question is how to do this ? thx in advance, andreas
|
|
|
|
|
I've not done this sort of thing, but two different ways of approaching it spring to mind.
1) You could make the second window a member of your main window's class. That way you can
access the members and functions of the secondary window.
2) You could simply get a pointer to the secondary window's class and then using that, access
the members of that dialog's class.
Perhaps combine the two approaches by making a pointer to the secondary dialog a member of
the primary dialog's class. That way you will always have that pointer available.
Then any time your primary window gets moved (in response to the WM_MOVE message)
you can call the secondary window to update it's position.
I hope that helps. David.
|
|
|
|
|
Handle the WM_MOVE message, which is sent after a window has been moved. When one of your dialogs moves, change the position of the other one calling MoveWindow or SetWindowPos.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
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.
|
|
|
|