|
Hello,
I want to open a dialog box openfile but I don't know how to make it open always in the same directory (the directory where the .exe is), in a MFC project of course
Thanks.
|
|
|
|
|
I guess you're using CFileDialog , right? If so, then between the construction of a CFileDialog (let's call it dlg ) and the line to dlg.DoModal() set dlg.m_ofn.lpstrInitialDir to the path of your exe. This path you can obtain with ::GetModuleFileName(NULL,...) , stripping the .EXE file name out of the result (leaving then only the path, which is what you want).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi !
It´s possible to convert from OLE_HANDLE to a normal HANDLE ( for example HENHMETAFILE).
What´s the difference between a Handle and one OLE_HANDLE ?
Thanks in advance, Bye !
Braulio
|
|
|
|
|
I have a project which I added to another project in an effort to make the new project dependent on some of the classes there. In VC studio, I check the box so that the project is dependent on the new project. I added the header into the old project for the class I want to use but I get linking errors.
What am I doing wrong? I do not want to always add the classes I write into every project each time.
Thanks in advance. I have received so much help lately and appreciate it very much.
|
|
|
|
|
You get automatic linking of projects thru the dependency check only when the project depended on is a library (static or a DLL). Otherwise, the dependency tool just checks that relative building dates are consistent. If you want to have some of the source code for app A into app B, you have no choice but to add the .cpp files to the new project.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Even though they're dependant on each other, they are still separate projects. The dependancy options in the IDE simply allow you to ensure that one project is up to date before the other is compiled.
This is great if one project is for example a DLL or a LIB that the other depends on.
From what you said, it looks like you want to use a class from one project inside of another. There are a number of ways to do this:
1. If the class in inside of a DLL and exported, you can use it from there.
2. You could use the class in source form. You need to add the files from the class to your project (cpp and h files)
I think that (2) is what you want to do. In this case, your class project does not need to be a dependancy of the other project, because you are using source code, not compiled code. therefore it doesn't matter whether it's been compiled in one project or not.
JOn
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
ok. the following scenario: i have an edit-ctrl (CEdit). i want to show a path to a file in this edit-field. as you all know, paths become very long and almost never fit into the control. the only thing, the user reads is c:\program files\mytool\... and the interesting things (at the end) are hidden each time i change the text in the control. just because the text is scrolled to the very left, after UpdateData(FALSE).
when i check the "right-aligned" style in the dialog-resource-editor, text shorter than the control-area is indeed aligned right, but if it gets longer than the edit-ctrl-rect, it is aligned left again. - besides: it really looks ugly when printing the short path rigth-aligned. so this option doesn't work for me.
does anyone know the mysterious function: CEdit::ScrollToTheVeryRightSoYouSeeTheEndOfTheString()???
or does anyone have an idea for a workaround (some HSCROLL-thing or whatever)
thx in advance
:wq
|
|
|
|
|
How about
<br />
CEdit::ScrollToTheVeryRightSoYouSeeTheEndOfTheString<br />
{<br />
CString cs;<br />
int len;<br />
GetText(cs);<br />
len = cs.GetLength();<br />
SetSel(len, len);<br />
}<br />
didn't try it out so it may not work.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous musi
|
|
|
|
|
Try this:
void ScrollCEditToTheVeryRightSoYouSeeTheEndOfTheString(CEdit &edit)
{
CString str;
edit.GetWindowText(str);
int nLength=str.GetLength();
edit.SetSel(nLength,nLength);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
ok. same idea both. good idea both
it works! great dudes!
:wq
|
|
|
|
|
i have a IR-MATE (infrared reciever + remote control) for the serial
COM port. i need to write a similar program for it:
if someone pushes the '1' button on the remote control, the program
should recognize and display it. the problem is that i have no idea
of programming the COM port in Visual C++.
whats the best and easyest way to do it ?
please help!
thanks!
|
|
|
|
|
You can open the COM port using ::CreateFile(...) and then read the chars as any other file.
Look up CreateFile in MSDN, it's quite a big topic. There's also a link there to a special section on communications.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi,
Which is the function to be used to get the Driver associated with a DSN...
Plese Help
|
|
|
|
|
|
Ooo,thanks Nish ,I saw this question yasterday and also today,and I thought and search a lot to find them,but I forgot their name and I don't know where the hell they
hide in my MSDN library.
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 used CFindFile class but that is so many exe files..
so, i serched regester information but is OS each other path..
finally i find winini files but that is anypath noting..
how do this problem??
|
|
|
|
|
|
Wow. You didn't understand that either?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
|
can anyone help me figure out y my dialog box or messagebox wont show. it only shows after i press the alt key. well, i wrote a class and made mostly everything be displayed in it. any ideas y that is happening?
|
|
|
|
|
What are you calling in order to get the dialog box and message box to appear>
::DialogBox(...)
::MessageBox(...)
::CreateDialog(...)
Will these windows appear if you press any other key besides the ALT key?
Is this window the only window in your application, or is it a child window of some other window?
|
|
|
|
|
|
umm... i used.. CDialog dlg(this) then i type dlg.DoModal()... it only show when i press alt key or F10. i dont know, coz i wrote my MFC program from scratch rather than using the Wizard. my other problem is my OnPaint hander. i am using it but it seems not to work. i create a fuction called DisplayBoard and i put it on the my OnPaint function but it still wont update my Board when i minimize it. i think its the same problem with my messagebox or dialogbox. i called MessageBox("text","title"), it shows but after awhile it loses it focus even though i didnt press OK.
|
|
|
|
|
Hi, I have written a program that saves graph data to files. I would now like to double-click on these files to start my program and open the file up. (rather than starting the program and selecting file-open)
How do I pass the double-clicked file name to the program???
Thanks
-------
Signatures come and signitures go
but this one smells bad!
|
|
|
|
|