|
This might be a dumb question, but I have spent weeks trying to figure it out, so here goes. When I first start my MFC app, is there a way to get the applications path? That is, the path to where the application's exe file is? I need this information, so I can access the help file, text files, etc which are in the app path. I have tried MSDN, the web, 'hacking' existing functions, etc, but so far have had no success.
|
|
|
|
|
Hi.
Pls use the function GetCurrentDirectory()
Regard
Luu Truong Huy
Vnetsoftware, USA
|
|
|
|
|
use GetModuleFileName
Nish
|
|
|
|
|
Use __argv[0] to get the complete filename of the .exe - __argv is the global variable. Then, perform a reverse search for '\' using CString::ReverseFind to cut the exe name from path.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
This code I find on the PJ Naughter's site (http://www.naughter.com/)
CString CSpltestApp::GetHomeDirectory() const
{
TCHAR sFilename[_MAX_PATH];
TCHAR sDrive[_MAX_DRIVE];
TCHAR sDir[_MAX_DIR];
TCHAR sFname[_MAX_FNAME];
TCHAR sExt[_MAX_EXT];
GetModuleFileName(AfxGetInstanceHandle(), sFilename, _MAX_PATH);
_tsplitpath(sFilename, sDrive, sDir, sFname, sExt);
CString rVal(CString(sDrive) + CString(sDir));
int nLen = rVal.GetLength();
if (rVal.GetAt(nLen-1) != _T('\\'))
rVal += _T("\\");
return rVal;
}
I frequently use it, work perfectly!
Best regards,
Eugene Pustovoyt
|
|
|
|
|
I have the class based from CScrollView! How to make so that scrolling it was carried out not in all window, but only in any part!
For example, I want to place not scrolled heading to the top of View!
|
|
|
|
|
Capture WM_SCROLL and then don't pass the message on if the values fall outside the area you want.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
The device context you're receiving in CYourView::OnDraw is prepared to draw using coordinates altered by current scrolling position. If you want top part of your view to remain top regardless of the scrolling, you have two options:
1) draw the top part not at the (0, 0) coords, but at the position returned by GetScrollPosition - this should be the top-left corner of visible area (I'm assuming that you're running in MM_TEXT mode).
2) use other device context for top part of the view in OnDraw - just declare a CClientDC. Draw at (0, 0).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Basically such it is possible! Whether it is possible to make the size scroll bar, only on height of a scrolled part! If yes that as!
|
|
|
|
|
So you want scrollbars to start not at the top of the window, but in lower part? In such case, simply create two views - one for the top part, without the scrolling and one derived from CScrollView for the bottom part. You can combine two views with CSplitterWnd or you can handle frame resizing yourself - in such case, the top part's size could remain fixed and user would be unable to resize it.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thank you!
I shall try!
Eugene Pustovoyt
|
|
|
|
|
You may notice that if you are logged on, and are viewing messages posted by others that are logged on that there is now a 'This Helped!' link at the bottom right-hand side of the message.
It's a great way of saying 'thanks' and gives us the opportunity, should it be a success, of handing out some prizes to those who help others.
If someone answers one of your questions and is helpful, please do them a favour and click on that link. It opens up a small separate window so your viewing won't be interupted.
cheers,
Chris Maunder (CodeProject)
|
|
|
|
|
Cool - there's prizes ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
That's the plan, but if it's abused then there is no point.
The whole thing is designed to encourage readers to help each other out and to give you the chance to pat each other on the back.
cheers,
Chris Maunder (CodeProject)
|
|
|
|
|
I think its already being abused.
look who is at number 1 spot.
Nish BusterBoy, Who has he helped !!!!
|
|
|
|
|
|
Can some point me to some documents or website that describes the MSDEV .bcs file format? I want to genertate my own to be read my CodeWrite from a custom langauge.
Thanks,
RZ
|
|
|
|
|
I'm pretty sure MS has an SDK for dealing with .BSC databases, but I've tried a few searches and can't find it now. Check around the MS Visual Studio site, maybe you'll have better luck than me.
--Mike--
http://home.inreach.com/mdunn/
This posting is provided "as was" with no warranties, guarantees, lotteries, or any of those little bags of peanuts you get on planes. You assume all risk for crossing the street without holding mommy's hand. © 2001 Mike's Classy Software. Member FDIC. If rash develops, discontinue use.
your with and
|
|
|
|
|
KB article Q153393 has links to 'Browser Toolkits' for all versions of VC++.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks this was very useful. Unfortunately, the SDK does not allow writing new information to the .bsc file, just reading a searching it (unless I'm missing something obvious). They supply a .dll that does all the reading, so the file format is still a mystery. What I need to do is create .bsc files.
Thanks, RZ
|
|
|
|
|
Hi,
can you help please a newbie how to
1.maximize a view
2.set one of views to the foreground
in an MDI app.
Thanks
Pe
|
|
|
|
|
1. In the view GetParentFrame()->ShowWindow(SW_SHOWMAXIMIZED);
2. I'm guessing in the view do the abvoe with SW_SHOW, or use the same technique to get a HWND to call SetWindowPos on.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
If by 'view' you mean MDI child frame, this is the way to go:
1) MDIMaximize
2) MDIActivate
Both methods are available from CMDIChildWnd (this is the base class for CChildFrame) and CMDIFrameWnd (the base for CMainFrame).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I have this code but need to be able to concatinate the two strings passed in using the overloaded + operator function. Help.
#include "myString.h"
#include <iostream.h>
#include <string.h>
myString::myString() // default constructor
{
length = 0;
stringData = new char[1];
}
myString::myString(char *A) //conversion constructor
{
length = strlen(A);
stringData = new char[length];
for (int I=0;I<length;i++)
{
="" stringdata[i]="A[I];
" };
}
void="" mystring::show()="" shows="" the="" converted="" string
{=""
="" for="" (int="" i="0;I" <="" length;i++)
="" cout="" <<="" stringdata[i];
="" endl;
};
int="" mystring::lengthof()="" returns="" length="" of="" return="" (length);
};
mystring="" operator+(mystring="" a,mystring="" b)
{
="" (a);
}
ostream="" &operator<<(ostream="" &a,="" mystring="" &b)="" done
{
="" a="" b.stringdata="" endl;
="" a;
="" for(int="" b.length;="" i++)
="" a<<="" b.stringdata[i];
="" };
="" a;
};
istream="" &operator="">>(istream &str_in, myString & d)
{
cout << "Enter string: ";
str_in.getline(d.stringData,32000);
//cout << "Enter string 2: ";
//str_in.getline(d.stringData,32000);
//str_in.get();
return(str_in);
};
void main()
{
myString string1;
myString string2;
cin >> string1;
cin >> string2;
//cout << string1.lengthof();
cout << string1;
cout << string2;
}
|
|
|
|
|
What about this.
myString operator+(myString A,myString B)
{
int nLength = strlen(A);
nLength += strlen(B);
char* pStr = new char[nLength+1];
for(int nCnt = 0; nCnt++; nCnt < (strlen(A)-1))
pStr[nCnt] = A[nCnt];
for(nCnt = 0; nCnt++; nCnt < (strlen(B)-1))
pStr[strlen(A)+nCnt] = B[nCnt];
pStr[nLength] = 0;
myString str(pStr);
return (str);
}
Think it should work.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
"Don't belong. Never join. Think for yourself. Peace"
- Victor Stone
|
|
|
|