|
let me test it
Thanks
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I need to display text in an edit box. Now, I need to use a function other than SetWindowText because it doesn't allow me to display an array. Any suggestions?
|
|
|
|
|
What do you mean it does not allow you to display an array, an array of characters, or an array of strings?
Are you dereferncing your string in the array of strings that you want to display?
|
|
|
|
|
One method is to associate a CString (say, m_myText) with your CEdit box, update the varialbe (m_myText) and call UpdateData(FALSE).
|
|
|
|
|
Why would another function exist to do the same thing, but differently ? If you hav an array and you want to show all of it in the title, you'll need to build a string that contains the array elements as you want them.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
Hi,
I'm wondering how coudl I insert a "File Edit View.." standard Menu on thetop of CMyDialog class.
I found information about inserting a ToolBar and I added it succesfully (with RepositionBars(), at least!), but nothing about the menù
Any help will be appreciated!
Bye.
|
|
|
|
|
You can add a menu resource to a dialog using the resource editor. Nothing special is required in order to do this.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
1. create your menu resource in the menu editor.
2. Call:
<br />
HMENU hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(ID_MENU));<br />
Where ID_MENU is your menu resource handle and hInstance is the instance to your current application. You could also use
<br />
::GetModuleHandle(NULL)
this will load your menu resource and assign it to an HMENU.
3. Call the SetMenu member function of your CDialog class in order to assign this menu with your dialog window.
If you want to change the menu out later or get rid of this menu call SetMenu with a new menu handle or NULL, respectively.
When your app is done, free the menu resources with DestroyMenu(hMenu);
You can also associate a menu with a dialog if you have created a special class that subclasses the dialog class by setting the MENU field in the CLASSINFO structure before you register your class.
If you would like more details on this method feel free to ask.
|
|
|
|
|
Just go to dialog editor,in property page of dialog,there is
combo box to set your menu.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I like both the static and the dynamic solutions.
(I love this board, too)
|
|
|
|
|
Hi
I'm fairly new to MFC programming and am busy building my first "serious" application for my own use. It is an online diary - I've put together an MDI application (so that I can set the background colors etc.) derived from CRichEditCtrl. I've managed to work my way through allowing the user (me!) to change font, font size, bold etc. etc.
I am a bit stuck now, though. What I'd like to do is remove the necessity to manually save each day's document. I would like to put the following in place: each time I start the app, it checks the date, and then checks to see if a document exists for this date. If so, it automatically opens the appropriate document so that I can add to it. If not, it opens a new document which will then be automatically saved at the end of the "session".
As far as I can work out, I need to find a way of automatically saving the document with "today's" date whenever a session is ended. I have found out how to automatically save an existing doc when exiting the app, and reload it when restarting the app. BUT... I don't know how to specifically save a new document using a filename that I generate, rather than the user having to specify one.
Can anyone please help? As I mentioned earlier, I'm new to MFC programming, and I'm doing this program as a "learning exercise". So far, I have found this site to be amazingly full of useful info (thank you to all programmers who take the time to help others!!)... and I'm hoping that someone out there can help me with this (small) problem.
Thanks
Keith Goddard
Pietermaritzburg, South Africa
|
|
|
|
|
If you are using MFC's Document / View architecture, you could generate the name of the file that you want to give your new file, and set the file name of "today's" document with the SetPathName member function of the CDocument class.
Then with the code that you have already written to automatically save files with the names, this should work with out asking the user for a file name.
|
|
|
|
|
Thanks kilowatt
I'll give this a try... and I'll let you know how it works out too. If anyone else has any suggestions, I'm "all ears" I'm sure this a problem that many new programmers have to deal with, so I'll definitely update this thread as necessary, maybe with sample code too.
|
|
|
|
|
Hmm... this didn't actually work out too well. The SetPathName function did manage to set the file name, but the default "Save As" dialog box was still called, just with the file name already set. My primary goal was to eliminate the appearance of the "Save As" dialog box, so I've only half solved the problem.
Perhaps its the way that I am automatically saving existing documents when the app closes? All I've done to accomplish this is override the SaveModified function. Now, I've added code to this function to check whether the document is named or not. If it isn't, I call the SetPathName function. Sample code:
BOOL CMyDoc::SaveModified()
{
if(!IsModified()
return TRUE;
CString strDocName;
strDocName=GetPathName();
if(strDocName=="")
{
COleDateTime today;
today=today.GetCurrentTime();
strDocName=today.Format("%d %B %Y");
SetPathName(strDocName,TRUE);
}
return DoFileSave(); //this line actually does the "autosaving"
}
It seems to me that I need to do something other than just call DoFileSave() at the end if I want to avoid the "Save As" dialog box. Or am I not using SetPathName correctly?
|
|
|
|
|
Hi,
I hope this isn't too dumb of a question. I need to add some custom icons to an app (for an image list), but when I tell the resource editor to stick one in for me, it just makes a standard 32*32 icon. How do you add a small icon?
Thanks
|
|
|
|
|
Go to Image -> New Device Image to create a new 16x16 "view" for the icon. Then Image -> Delete Device Image to erase the 32x32 view.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Finally I know how to delete one. Thank you so much!
|
|
|
|
|
it's amazing how well that function is hidden... right in plain site. i swear, it took me over a year to find it.
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
it took me over a year to find it.
So did it take to me! In fact, before knowing about this command, when I wanted to insert a 16x16 only icon, I resorted to such an icon of my own and imported it into Visual Studio (then I'd change it inside VS). That little icon I took great pains to obtain in the first place, and was one of my little treasures --stupid as it may seem now
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
No kidding.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Oh,thanks Joaquin,I never knew there is something like that.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
an icon resource contains both 32x32 and 16x16. There's a little drop down box in the icon editor to select between them.
bitmaps are more suited to imagelists.
jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Is it possible to get the HWND of the Window which has focus (not only a window of my app but any opened window) ?
Thanks !
|
|
|
|
|
This is taken straight from MSDN:
"
The GetForegroundWindow function returns a handle to the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.
HWND GetForegroundWindow(VOID);
Parameters
This function has no parameters.
Return Values
The return value is a handle to the foreground window. The foreground window can be NULL in certain circumstances, such as when a window is losing activation.
"
Hope this helps.
Roger
|
|
|
|
|