![]() |
|
#1
|
|||
|
|||
menu creationhi ,
i want to know how to link a newly created menu with the coding written on OnDraw function. in detail: i made a grid using on draw function and i need to create a menu, let me label it as 'diagram' which has cells as 'ondraw' 'indraw' where if i click 'ondraw' cell the particular grid should be displayed. pls tell me how. |
|
#2
|
||||
|
||||
|
I think no one rplys to your original post because thay can't help without you decribing in more detail what actually you want to do...
is it dialog or sdi application?? is it a context menu or you want to rplace the main menu??? and what is it you do in the OnDraw function that you want to link to... __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#3
|
|||
|
|||
|
Quote:
it is an SDI application. i created a context menu. in the ondraw function i drew up a grid. i want to know how to display the grid if i clk a cell,by name grid, in the menu.pls tell me |
|
#4
|
|||
|
|||
|
hi
im repeating the same problem,someone pls help me. mine is an SDI appln. i created a context menu. i had a cell in that context menu by name 'grid' on clicking which i should get a grid drawn. i have already written the coding for the grid in the 'ondraw' function of view class. so now i need to know how to call it. hope im clear. pls reply me. |
|
#5
|
||||
|
||||
|
Hi,
for a context menu, there is a function which handles the contect menu creation and manipulation.its called the OnContextMenu, open your class wizard and search for this function and add it to your proect.. CPP / C++ / C Code:
the above example is for creating a menu without using the resource editor, here is an example of how to create a menu from the resourse editor.. CPP / C++ / C Code:
now how do you handle mesage for each menu item, ID_FIRST, and ID_SECOND?? put it in your message map.. CPP / C++ / C Code:
BTW: the code above might not run properly, since I don't have a VC++ on my pc to test it, so use it as a guide... __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#6
|
|||
|
|||
|
hi,
thanks a lot. i want 2 know how to call the ondraw function of viewclass if i click the menu which i created.while trying that i got 3 error which i have mentioned below: error C2143: syntax error : missing ';' before '*' error C2501: 'CSamDoc' : missing storage-class or type specifiers error C2501: 'GetDocument' : missing storage-class or type specifiers i've declared the viewclass header file in the corresponding class of the resource. i donno whether is it rcorrect or not. iam beginner in vc++, so if u find any of my doubts to be silly pls bear with me. |
|
#7
|
||||
|
||||
|
First: don't call your OnDraw function on your own, it is reserver for the windows to call on event of WM_PAINT !!
can you post what code is in the OnDraw function, maybe we can figure out to write the code on another function, not in OnDraw. and also post the line of code which produce the error. and also where did you include the view class header file?? Quote:
i don't find your doubt is silly, but you should be more detail in xplaining your problem, no one is a magician here who could guess and figure out your problems... you must explaine in detail, what you want to do, post some of your codes involved... __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#8
|
|||
|
|||
|
hi
to write the entire coding, that is in my ondraw function, here will be too lengthy. to tell u wats there,it is just to print a grid(simply by using MOVETO,LINETO etc). the code that produces error is in samview.h file('sam' is my proj name) it is as follows. public: CSamDoc* GetDocument(); --all three errors which i said earlier points to this line only. i included the view class header file in the mainframe.cpp file. as the menu which i created is in the mainframe class. i wanted to know how to print the grid if i click the menu. i mainly want to know how to call ondraw function when i click the menu. |
|
#9
|
||||
|
||||
|
Ok, figure how to clear the error first:
your context menu is for your view right? so put your context menu in your view class, don't touch the mainframe class, so no need to include the view class there, and move your code for the context mnu to the view class.. Now, OnDraw should not be called directly, so make a new function say "DrawGrid()" and cut and paste the code in OnDraw to the new function, then call that function from your OnDraw().. and onCommand for the context menu, call also the DrawGrid function.. did that solve your problem? if no, please post your coding, or attach the file involved.. __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#10
|
||||
|
||||
|
BTW: I recomended the context menu is handled in the view class becaus its supposed to be the context menu for the view, and its a lot neater handling it from the view class...
but you also can proceed what youre doing but then itll be a litle messy as you have to call the memberfunction of the view class from the mainframe by casting pointer to the class... so, if you want to manage the context menu in the mainframe.. just #include "CSamDoc.h" #include "CSamView.h" to the mainframe.cpp. __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
Recent GIDBlog
Developing GUIs with wxPython (Part 4) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Photoshop Tutorial: Make An Inspirational/Mystical Picture | ToddSAFM | Graphics Forum | 9 | 09-Aug-2005 20:32 |
| Popup menu | gavrile | MS Visual C++ / MFC Forum | 8 | 12-Aug-2004 01:50 |
| javascript menu | dopee | Web Design Forum | 7 | 30-Jul-2004 23:22 |
| Great way to disable flash rightclick menu | BobbyDouglas | Web Design Forum | 0 | 02-Sep-2003 18:23 |
| top menu bar trouble | chalaska | Web Design Forum | 3 | 18-Jul-2002 21:11 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The