Yes I added %1 in registry c:\Documents and Settings\user\My Documents\Prog\Prog.exe %1 Is it correct? but I am not sure whether it should be separated by space or a comma ',' when I add the following code to: BOOL CProgView::PreCreateWindow(CREATESTRUCT& cs) {..... LPTSTR str = ::GetCommandLine(); AfxMessageBox(str); ..} The str contains one long string "c:\Documents and Settings\user\My Documents\Prog\Prog.exe c:\Docum~1\use~\Desktop\test~1.cmp" I guess its what I should get but its a bit silly to have one long string as it will be a hassel to separate one argument from the other as the are blank spaces all over the place so it will be hard to determine where to split it.
robert_s
Posts
-
Open a file.myext via contxt menu in my application -
Open a file.myext via contxt menu in my applicationNo. I did update registry myself. all keys are added and working well! its just when you right-click on the filename.cmp it opens teh program which is correct but the programas isnt able to know what file was selected.
-
Open a file.myext via contxt menu in my applicationHi. I recently wrote a small MFC app that saves files in my own format .cmp I also managed to associate this file extension with windows so my files have their own cutom icon rather than the default windows one. I learned how to do it from here (cool stuff): http://www.codeproject.com/w2k/extendingshell.asp Now I am facing one problem. When I double-click on any saved file say stored on my desktop then my application opens as it should but it doesnt open my file. Obviously its because when my application initializes it should know the name of the file that I selected to open but I am not sure how to retieve this info. I guess when I right-click on the saved file and select from a context menu "Open this (.cmp) in my app" the shell Command will call my app and somehow pass the name of the file. So basically I am not sure how to read this command line arguments in my MFC app so I could get the name of the file and open it immediately after my app initialization. Actually would it be a command line or some other way of doing it? how do I tell my app what file I am opening.? Please let me know if its very easy solution for it. In that tutorial the author calls: C:\Windows\Notepad.exe %1 but I guess "%1" means nothing to my app as my app would not recognise what that is. I think I should replace %1 with my own command like "open" or "print" to distinguish the action my app should perform. Am I right? Please let me know if you could. Thank you..
-
Displaying a short movie in same window over 3D display - need an adviceHi all. I have a win32 window where I display my little 3D game using DX9 in full window size. I managed to load a QuickTime movie in same window but instead of movie I can still see my game rendered. Only while resizing the window teh movie appears. Also if I disable my 3D drawing then I can see the movie correctly. I am sure its something wrong with HWNDs or its something else? How can I solve it. Actually can somebody adivise me on this problem. What is the proper way to handle these two things. (displaying a movie and displaying 3D game world)? Note: I only want to have a single window and displa one thing at a time. So, when I want to watch a movie then the movie will be displayed in full window size and should be able to switch with a single key press back to my game again occupaying the entire window display. Apparently in windows I can create more than one display surfaceses. Should I do that or I can easily use one surface to manage that? Later I am planning to capture my 3D game into a movie file but I guess I'll worry about that later Thanks for your help in advance. ---------------------------- Robert Stuliglowa
-
Is it Modeless or Modal dialog. I'm confusedHi As far as I know there are two types of dialogs. Modeless and Modal. Now according what it says here : [url]http://www.devarticles.com/c/a/Cplusplus/Using-MFC-in-Cplus-Dialog-Boxes/4/\[/url\] and also on Microsft's MSDN site that to create Modeless dialog I must call Create() function and DestroyWindow() function. Whereas for the modal dialog I only call DoModal. Now I am confused as my dialog does not call any of those functions and I am still able to display it. The dialog initialization is: BOOL CProgressDlg::OnInitDialog() { CDialog::OnInitDialog(); ShowWindow(SW_HIDE); // Show or hide a control, etc. return TRUE; } and to display I call ShowWindow(SW_SHOW); and Close() function to close dialog: void CProgressDlg::Close() { EndDialog(IDOK); } It works.! So what kind of dialog is this? I guess this is a modeless dialog as it doesnt need to wait untill the user presses OK button. Is it correct what I am doing here or its wrong? Please let me know. My second question: The dialog I created is used to display a progress bar while some text files are processed using a separate worker thread (thread used purely for files processing not for the dialog). The problem I have is when I start processing files the dialog with the progress bar appears but its behind the main window. How can I force it to display over the main window as the modal dialogs do? I guess WS_OVERLAPPED will do but where to use it?
-
import lib file in VC.NetThere is no need to write your lib name in project settings. The easy way is to just point to the directory the .lib file is stored or as already mentioned, like normaly you do with .h file ie. #include "test.h" with lib you write : #pragma comment (lib, "test.lib") wherever you use your library. thats it. Make sure you compile your libraries in release mode when creating the .lib Hope this helps :o)
-
Main Window Icon loadingOk thank you. Cwnd::SetIcon() solved my problem :)
-
import lib file in VC.NetIn Solution Explorer (left hand side widow). Clik properties/linker/additional Library directcories/ (point to directory where your lib is)
-
Main Window Icon loadingHi. Usual question. How can I load an Icon into my main MFC window. I already searched on this web site for answers but obviously they won't work for me. I tried several differnt ways: I then tried this : BOOL CMyAppView::PreCreateWindow(CREATESTRUCT& cs) { if (!CWnd::PreCreateWindow(cs)) return FALSE; m_hIconFrame = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME)); cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, ::LoadCursor(NULL, IDC_ARROW), reinterpret_cast(COLOR_WINDOW+1), m_hIconFrame ); return TRUE; } Then I tried : in MyApp::InitInstance() { AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME)); <--- this wont work CWinApp::LoadIcon(IDR_MAINFRAME ); <------------------------- this wont work too m_pMainWnd = pFrame; // create and load the frame with its resources pFrame->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); } Then I tried in int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct). Still no luck.. However same function call ie. AfxGetApp()->LoadIcon(IDR_MAINFRAME); in my dialog class displays the bloody icon ok. what is going on? Why can't I see this icon in my main window caption bar? ARGH.... Can somebody help please. thank you.
-
SetFocus for a chosen Edit Control in MFCThanks toxcct :o) Returning FALSE fixes the problem :) HAHA!!! S*** I haven't noticed these comments generated by a wizard. How embarassing.... Sorry! But still its a bit silly to me to return FALSE. The function name (OnInitiDialog) suggests that I am initializing a dialog and if successfully initialized it should return TRUE otherwise FALSE if unsuccessful. But here even though the dialog is initialized I am returning FALSE. hehe! I cant see any logic here? Perhaps I still need to learn more the way how MS people think :o) hehe.. Thanks all for help!!
-
SetFocus for a chosen Edit Control in MFCHi. I am writing an application where I have a dialog with one combo box and 4 edit controls. Now when I open that dialog there is always first edit control focused. How can change this behaviour so for example rather than the first I would like the third edit control to be automatically focused, so when the user opens the dialog one can start typing into that (third) edit control rather than using a mouse to click on it first. I thought it would be as simple as that: BOOL CTestDlg::OnInitDialog() { CDialog::OnInitDialog(); CtrlSourceExt.SetFocus(); // PROBLEM IS HERE - Set foucus to this edit control (this Doesn't work) (NOTE: variable CtrlSourceExt is of type CEdit) UpdateData(); return TRUE; // return TRUE unless you set the focus to a control } Actually I remember in VC++ 6 I could specify the order of things to be focused in resource editor when designing a dialog. So if I had say 4 edit controls I could set focus in this order 4,2,1,3 so the first hightlighed edit control would be 4 then if the user pressed tab once it would take him to edit control 2 then 1 and 3. But now in VC++ 2003 .NET it doesnt work. Same thing with profiler I just cant find it. I dont know why they got rid of such useful thing. Anyway going back to the subject. Can anybody help? Thanks.