|
Learn Charles Petzold "Windows Programing" by heart.
Next trawl thru the MFC samples.
Look at other peoples code.
The most difficult aspect to MFC is getting this Window from another window.
Example:
Application
MainFrame
Document
View
Toolbar
DlgBar
DockingDialogBar
Combo
Some other Control (SOC)
Now take an example where you want to communicate to from SOC to any other element in the Windows app?
I will demonstrate this technique in an article I'm preparing, just for a note I ask the same question to Jeff Prosise at a Windows Development Conference an he could'nt give me the actual answer.
It's quite easy a simple map store at app level so you can get at any window with little indirection.
|
|
|
|
|
I recommend:
Programming MsVisual C++ Fifth Edition[^]
Authors:
David J. Kruglinski
George Shepherd
Scot Wingo
great book from Ms Press.
Daniel Cespedes
"There are 10 types of people, those who understand binary and those who do not"
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
I read in an Amazon.com review that MFC programming will soon be going by the wayside, is this true? I thought it was here to stay. what would would replace MFC to create Windows programs? I want to learn MFC programming, or should I focus elsewhere?
Thanks
|
|
|
|
|
i just wrote a program in good old turboC from 1994. languages may get old, but they'll never go obsolete.
*.*
|
|
|
|
|
I remember working with that! Must be a DOS program. How fast does it run on today's hardware? Must be blazing!
onwards and upwards...
|
|
|
|
|
Not likely that it will die out, anytime soon at least. There is too much code base and too many MFC developers. C# and .NET are really nice and I would recommend you looking at them too, Inside C# Second Edition by Tom Archer. But I wouldn't drop MFC yet.
Matt Newman
"Two things have come out of Berkley, Unix and Acid, we do not belive this to be a coincidence" Linux sucks twice as fast and 10 times more reliably, and since you have the source, it's your fault. -Ca1v1n
Post best viewed with lynx
|
|
|
|
|
DaveE9th wrote:
I read in an Amazon.com review that MFC programming will soon be going by the wayside, is this true?
Too good to be true, I am afraid.
|
|
|
|
|
So what is the latest and greatest over MFC to design Windows based programs, C#? How about MFC.net? Would you recommend I start with MFC, or start with something newer and forget MFC? I'm trying to decide if I should spend the time trying to learn MFC. Decisions decisions...
Dave
|
|
|
|
|
WTL Windows Template Library (only downside it's not *YET* supported by microsoft).
For heavy duty desktop programming eg. Visio, Word, Excel, Point and Click or document centric appd. use MFC
For simple destktop windows apps use WTL ( very lightweight)
For controls use ATL. (lightweight no dll's to carry)
For web apps use ASP.NET
For lightweight console apps use straight C++ or C
For data-centric (form based ) apps use C#
These are my own opinions base on 10 year windowing programming experience other people may agree or disagree, the choice is yours.
|
|
|
|
|
Normski wrote:
For heavy duty desktop programming eg. Visio, Word, Excel, Point and Click or document centric appd. use MFC
Interestingly enough, none of these applications (except maybe Excel) were developed with MFC.
|
|
|
|
|
I heard that Word still has thousands of lines of legacy C...might be different for Word 2003, etc. but I sort of doubt it. That stuff is probably still lurking around there somewhere.
|
|
|
|
|
Nemanja Trifunovic wrote:
Interestingly enough, none of these applications (except maybe Excel)
True, this is because they were all best on code pre '92 a mixture of tight C message crackers, no doubt.
|
|
|
|
|
Normski wrote:
WTL Windows Template Library (only downside it's not *YET* supported by microsoft).
Do you really feel that someone could easily start to learn WTL or ATL without understanding MFC? Wouldn't a solid foundation in Win32 be more appropriate for starting out with WTL?
-Nick Parker
|
|
|
|
|
MFC won't die. It may not be used for new projects and may not be developed futher, but it won't die. There are too many legacy projects that depend on it, and it's just too expensive to convert them to something else. Even COBOL and FORTRAN are still used extensively.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I've been looking into DirectX lately, more specifically Directdraw (even though technically speaking that doesn't exist anymore), because i wanted to sort of mimic the GUI of a certain game. This game has a menu on startup which is built up out of several bitmaps, all placed neatly together so they form one image. Then there is the menu on it which is formed by just drawing over the main image, rectangles that contain the text for the menuitem, so the menuitems must have a background to match the main screen. When you move your mouse over one of these items, the bitmap can change so the text appears to highlight or whatever. Now i have two questions:
1) Why did they break appart the main background image in several pieces? I mean, what reason could there be? Why didn't they just make the background image one large bitmap and then just draw the menu over it, so they wouldn't have to assemble the pieces of the background image first?
2) When you put the pieces of the background image together, you get an image of 640 by 480 pixels. Now, in the game you can switch resolutions, for example to 1024*768. So this would mean the bitmap would get stretched, how do you do this in DirectX? Is there a function, or do you have to write your own function to calculate how many pixels will be representing one pixel now?
Thank you for your help.
P.S.: i do have a theory for the first: The measurements of the pieces can all be divided by 16,32,64 or whatever, basically most pieces (also for game textures) are either 32*32,64*64,128*128,128*256,256*256 so maybe they just wrote a function that only handles certain dimensions of bitmaps like PaintBM256by256(). But i would think it would be easy to detect the size...
Kuniva
--------------------------------------------
|
|
|
|
|
Kuniva wrote:
Why did they break appart the main background image in several pieces? I mean, what reason could there be?
I'm not familiar enough with DirectDraw to be certain, but if the app is (or was planning to) use 3D acceleration for the 2D parts, then the author was just making sure that the image pieces will play nice with video card capabilities, particularly older cards. For example, the Voodoo 3 doesn't support texture sizes larger than 256x256.
- Mike
|
|
|
|
|
ah thanks! thats probably it really, the game is pretty old already
Kuniva
--------------------------------------------
|
|
|
|
|
Harumph. i've got a bit of code here that is suposed to read data from a text file, and based on the value of 'default_val' its supposed to make the string in my combobox display that is linked to a number.
ie, if default_val = 0, then the first string displays, 1 the 2nd string, etc
here's my code:
<br />
combovectorread( strings, var_nums, pointer, default_val);<br />
<br />
DDX_Control(pDX, IDC_INPUT_TQ, input_tq);<br />
input_tq.SetCurSel(default_val);<br />
<br />
<br />
for(int i = 0; i <= var_nums; i++)<br />
{<br />
input_tq.AddString(strings.at(i).c_str());<br />
}<br />
<br />
<br />
combovectorwrite(pointer, default_val);
here's what everything does: combovectorread() gets a vector fo strings (contents of the listbox), default_val is the number of the string i want to be default in the combobox. input_tq is my CComboBox object. combovectorwrite() outputs the value of default_val to teh text file.
Now, everything works fine when a user changes the selected string in the combo box. if they select, say, string 3, and move to another tab in the propertysheet, string3 remains selected. however, if they close the program and reload it, its back to the origional.
any suggestions? i know the input/output work properly, i've tested them and output to teh screen. I think my main question is finding where in the source code i need to have a GetCurSel(). I tried putting it before the combovectorwrite() and setting default_value to it, but it always sets default_val = -1. even if the 3rd string is selected.
*.*
|
|
|
|
|
I do not know if the code snippet you've provided is in any particular order or not, but you're gonna want to call input_tq.SetCurSel() after loading the combobox with input_tq.AddString().
keegan wrote:
I think my main question is finding where in the source code i need to have a GetCurSel().
When the dialog is being dismissed.
|
|
|
|
|
ok, i've modified my code. i only have one teeny tiny little bug. Say a user selects the 3rd option in a combo box. if the user goes to another page in the property sheet, the 3rd option remain selected. if a user closes the dialogbox, and reopens it, the 3rd option remains selected.
however, if the user closes the program, and loads the dialog box back up, the first option is selected. now here's the punch line: if the user moves to another tab in the propertysheet, then goes back to the one with the combo box, the 3rd option will be selected again.
funky, eh? its only when the propertysheet is first opened the fuirst time the app is launched does the first option appear selected. I've for input_tq.SetCurSel() functions up the wazoo, all over my program.
any ideas?
(and if i look in the text file where the values are stored, the value for the 3rd option is there, not the 1st. its wierd.)
*.*
|
|
|
|
|
What you need to remember is that in a property sheet, the actual page window is not created until that tab is selected for the first time. Could this have some impact on your issue?
onwards and upwards...
|
|
|
|
|
i'll bet thats it. i tried putting setcursel() right before my domodal, but the linker didnt like that. and since i dont use oninitdialog...
bleh, its friday, ill be back opn monday.
Edit: Why does an edit control show saved data the first time the page is displayed, but a combobox doesn't?
*.*
|
|
|
|
|
keegan wrote:
i tried putting setcursel() right before my domodal, but the linker didnt like that.
The linker couldn't care less in what order you've called a set of functions. But, given that the dialog window, nor any of its controls, exist prior to calling DoModal(), the call to SetCurSel() would indeed cause an assertion to fire.
|
|
|
|
|
ok, so if it goes ebfore the page is displayed, and after its created, where does it go? :-/
*.*
|
|
|
|
|
Well, the initialization code can either go in OnSetActive(), or since it is derived from CDialog, the code can also go in OnInitDialog().
|
|
|
|
|