|
Do you realy want to change the project name of just the .exe name? If just the .exe name then (1)select project settings (2)select like tab (3)change the output file name for both debug and release versions (4)change the name(s) in version info. resource and any where else where is might be stored (such as your about box and string table, etc...)
I just did the above today, since the internal project name was not acceptable for a released .exe name.
|
|
|
|
|
Hi.
Got a little question, i need to change the m_pszHelpFilePath member to another value.
Let's assume i have a dialog where i can click english or dutch help file.
If english, m_pszHelpFilePath = appname.HLP
if dutch, m_pszHelpFilePath = appnameD.HLP
(path need to be the path where the exe file is executing)
Does anyone know how to do this?
Greetings
Jens
|
|
|
|
|
Try this (MSDN):
free((void*)m_pszHelpFilePath);
m_pszHelpFilePath=_tcsdup(_T("d:\\somedir\\myhelp.hlp"));
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
yeah i found that too, but how can i know the current directory where the application is running?
And can i access this member everywhere?
|
|
|
|
|
This will give you the current directory where the application is running.
GetModuleFileName ( NULL, strPath, MAX_PATH );
m_pszHelpFilePath is a public member of CWinApp so you can access this member anywhere this way:
AfxGetApp()->m_pszHelpFilePath
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
yeah i've been trying it out:
char path[256];
GetModuleFileName(NULL, path, 256);
CString strFilePath = path;
int idx = strFilePath.ReverseFind( '\\' );
strFilePath.SetAt( idx, '\0' );
AfxMessageBox(strFilePath);
displays "c:\source\myprogram\debug"
free((void*)app->m_pszHelpFilePath);
app->m_pszHelpFilePath=_tcsdup(strFilePath);
it doesn't work .. he still takes the normal path but i think there is a problem with the '\'
i think he has to display "c:\\source\\myprogram\\debug"
Am i right, and so yes how can i easily fix this problem?
...
AfxMessageBox(strFilePath);
strFilePath += "\\MYPROGRAMF.HLP";
AfxMessageBox(strFilePath);
Why doesn't he add "\\MYPROGRAMF.HLP" to the CString????
i totally don't get it anymore
|
|
|
|
|
strFilePath in your program is the path the exe file. If your help file is there two then you don't really need the whole path. strFilePath = "helpfile.hlp". But if you want to proceed with the exe path then you need c:\source\myprogram\debug\helpfile.hlp". In your program all you have is c:\source\myprogram\debug.
Also check CWinApp::WinHelp
char szPath[ MAX_PATH + 1 ];
GetModuleFileName( NULL, szPath, MAX_PATH );
CString strPath = szPath;
int idx = strPath.ReverseFind( '\\' );
length_of_exe_file = 10;
if( idx != -1 )
{
strPath.Delete( idx+1, length_of_exe_file );
}
strPath += "helpfile.hlp";
AfxMessageBox( strPath );
free((void*)AfxGetApp()->m_pszHelpFilePath);
AfxGetApp()->m_pszHelpFilePath=_tcsdup(strPath);
JensB wrote:
it doesn't work .. he still takes the normal path but i think there is a problem with the '\'
i think he has to display "c:\\source\\myprogram\\debug"
\\ is a way for the compiler to read '\'. '\' is called an escape sequence I think. I might be wrong about the name.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
yes, this is a debug-build
i've put my HLP files compiled alsoo in the debug folder where the .exe file is executing.
But i still have the problem that "helpfile.hlp" is NOT added to the CString .. although AfxMessageBox() doesn't show it well
AfxMessageBox(strPath); //output: c:\myprogram\debug\
strPath += "helpfile.hlp";
AfxMessageBox(strPath);
//output: c:\myprogram\debug\
so "helpfile.hlp" isn't added to the string!?!?
any idea?
|
|
|
|
|
uhm i solved it like this: the file name (standard) was something like 'myproject.HLP' and the other file i changed name to 'myprojectF.HLP' .. and he loads the correct file now
still one question left
-> i wanted to use the member function Insert (CString::Insert(..) but when i compile, the compiles gives an error and says Insert(..) isn't a member of the CString class.
Code (bit messy)
----
CString strCurrPath;
strCurrPath = (CString) (AfxGetApp()->m_pszHelpFilePath);
int idx = strCurrPath.ReverseFind('.');
CString strRechterGedeelte, strLinkerGedeelte,strFull;
strRechterGedeelte = strCurrPath.Right(strlen(strCurrPath)-idx);
strLinkerGedeelte = strCurrPath.Left(strlen(strCurrPath)-strlen(strRechterGedeelte));
strFull = strLinkerGedeelte + "F" + strRechterGedeelte;
free((void*)AfxGetApp()->m_pszHelpFilePath);
AfxGetApp()->m_pszHelpFilePath=_tcsdup(strFull);
|
|
|
|
|
In your source code (in one of your previous postings ) you had something like:
strExePath.SetAt( idx, "\0" );
If you try to add a string to strExePath, you won't be successfull because the string will be added after the null character so you will never be able to se it. That's why I used Delete in the example that I gave you. But anyways, you found your own solution which is very good.
Now going back to your Insert question, I don't see you using it in your source code. How are you using it?
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
yes, i wanted to use the insert member function of CString because then i will be able then to delete three CString variables (strRechterGedeelte, strLinkerGedeelte, strFull) because they are then useless.
This doesn't work:
CString strCurrPath;
strCurrPath = (CString) (AfxGetApp()->m_pszHelpFilePath);
int idx = strCurrPath.ReverseFind('.'); //returns position of '.'
//Now i want to add the char 'F' at that position
int iLength = strCurrPath.Insert(idx, 'F');
AfxMessageBox(strCurrPath);
// error C2039: 'Insert' : is not a member of 'CString'
//!!!!Insert(..) is a member function of CString class
which is alot shorter then (but it works too):
CString strCurrPath;
CString strRechterGedeelte, strLinkerGedeelte,strFull;
strCurrPath = (CString) (AfxGetApp()->m_pszHelpFilePath);
strRechterGedeelte = strCurrPath.Right(strlen(strCurrPath)-idx);
strLinkerGedeelte = strCurrPath.Left(strlen(strCurrPath)-strlen (strRechterGedeelte));
strFull = strLinkerGedeelte + "F" + strRechterGedeelte;
AfxMessageBox(strCurrPath);
and btw, i work with Visual C++ 5
Greetings Jens
|
|
|
|
|
Hi,
I am trying put one rectangle in MemDC and bring to screen.
Here is the code:
CDC MemDC;
CClientDC mydc(this);
MemDC.CreateCompatibleDC(&mydc);
MemDC.Rectagble(&myrect);
MemDC.SelectObject(&mybrush); /////myrect and mybrush I created before
MemDC.FillRect(&myrect,&mybrush);
mydc.BitBlt(0,0,1024,768,&MemDC,0,0,SRCCOPY);
But I am not finding any output.
Help me.
Thanks
Satya
|
|
|
|
|
This can't work...you have to construct a compatible bitmap and select it into the memory DC. At the moment, you are simply drawing on "nothing"...and "nothing" is what you are bitblitting.
greets,
Jason
|
|
|
|
|
Hi,
Where I have to include that Compatible Bitmap??
That means I have to draw the things on the bitmap and move this to memory and bitblt to screen??
Can U please give some explanation,
Regards
Satya
|
|
|
|
|
>CDC MemDC;
>CClientDC mydc(this);
CBitmap bmMem;
>MemDC.CreateCompatibleDC(&mydc);
if (bmMem.CreateCompatibleBitmap(&mydc, nWidth, nHeight))
{
CBitmap* pOldBM = MemDC.SelectObject(&bmMem);
>MemDC.Rectagble(&myrect);
>MemDC.SelectObject(&mybrush); /////myrect and mybrush I created before
>MemDC.FillRect(&myrect,&mybrush);
>mydc.BitBlt(0,0,1024,768,&MemDC,0,0,SRCCOPY);
MemDC.SelectObject(pOldBM);
}
|
|
|
|
|
Hi,
Yes that should do it!
|
|
|
|
|
//Looks like you want to do flicker free drawing
//Which is the only reason for doing this
CDC MemDC;
CBitmap bmp;
CClientDC mydc(this);
MemDC.CreateCompatibleDC(&mydc);
bmp.CreateCompatibleBitmap(&mydc,1024,768);
CBitmap* pOldBmp = MemDC.SelectObject(&bmp);
// Draw rectangle
CBrush* pOldBrush = MemDC.SelectObject(&mybrush);
MemDC.Rectangle(myrect);
MemDC.SelectObject(&pOldBrush);
//TODO: Draw other things
//Blit to client DC
mydc.BitBlt(0,0,1024,768,&MemDC,0,0,SRCCOPY);
//Clean up
MemDC.SelectObject(&pOldBmp);
MemDC.DeleteDC();
Doing all of the above when you receive a WM_PAINT message is the slow way, but it works.
Find the article "Do a flicker-free drawing using MFC methods" here at codeproject. I have not read it but it should provide you with your answers.
Trust in the code Luke. Yea right!
|
|
|
|
|
Thank U all for the replies
I got it.
Regards
Satya
|
|
|
|
|
I need to create a new system level environment variable in my MFC code ..Is there any API for it ..
I think putenv() changes only the process level environment varaible .But GetEnv() retrives the system level environment variable !!!!
Help required for the above situation...
|
|
|
|
|
In Win2k/XP, global environment variables come in two flavors: system and user. For lack of a suitable API, you can directly access them via the registry at
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and
HKEY_CURRENT_USER\Environment respectively.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
dear Joaquín M López Muñoz'
Thanks a lot ..
But my doubt is that will the PATH for environment variables be same in all the WIndows OS starting from Windows 98????
If there is a API ,it would be much better ...
|
|
|
|
|
See SetEnvironmentVariable()/GetEnvironmentVariable() in the docs. Win95 and later.
|
|
|
|
|
This is the functin I'm working with:
void CJobQueueSimulatorView::LoadSkills()<br />
{ <br />
<br />
int numItems = m_skills.GetCount();<br />
<br />
for(int k = 0; k < numItems; k++)<br />
{<br />
m_skills.DeleteString(0);<br />
}<br />
<br />
char next[25];<br />
<br />
fstream fin(strCurrType + "_skills.txt", ios::in);<br />
<br />
if(!fin)<br />
{<br />
MessageBox("Could not open skills file!", "File Error", MB_ICONEXCLAMATION);<br />
}<br />
else<br />
while(fin >> next)<br />
m_skills.AddString(next);<br />
<br />
fin.close();<br />
}
What I would like to do is prepend a letter to each line I read from my text file. This would give me an I.D. that I can associate with each "skill". m_skills is a list box control variable. I don't want the letter code to be saved in the text file. I would like it to be assigned as the lines are taken from file and put into the list box. This would prevent users from assigning skills the same "I.D". Also, later when they add skills to the list, it would automatically assign an "I.D" I'm thinking the way to do it is with ASCII but I'm dumb and don't know how to do it. Anyone have a good idea of how to do it? (Sorry for the sloppy formnatting above. Things didn't copy over that well)
"It has become appallingly obvious that our technology has exceeded our humanity."
- Albert Einstein (1879-1955)
"I think there is a world market for maybe five computers."
- Thomas Watson (1874-1956), Chairman of IBM, 1943
"640K ought to be enough for anybody."
- Bill Gates (1955-), in 1981
"Half this game is ninety percent mental."
- Yogi Berra
|
|
|
|
|
strcat() example from MSDN:
<br />
<br />
#include <string.h><br />
#include <stdio.h><br />
<br />
void main( void )<br />
{<br />
char string[80];<br />
strcpy( string, "Hello world from " );<br />
strcat( string, "strcpy " );<br />
strcat( string, "and " );<br />
strcat( string, "strcat!" );<br />
printf( "String = %s\n", string );<br />
}
Output:
String = Hello world from strcpy and strcat!
|
|
|
|
|
char next[25];
CString str;
...
while(fin >> next)
{
str = some_unique_identifier + next;
m_skills.AddString(str);
}
|
|
|
|