|
You can take a look at the following functions...
CDocument::GetFirstViewPosition();
CDocument::GetNextView();
CMultiDocTemplate::GetFirstDocPosition();
CMultiDocTemplate::GetNextDoc();
Nibu thomas
Software Developer
|
|
|
|
|
I have a CString object loaded with a string like "This is the first section$This is the second section$This is the end" so each section separated by '$'. I try to load the second section as csAnsprech = csComboBoxText.Mid( csComboBoxText.Find( '$') +1, csComboBoxText.ReverseFind( '$')); but this retrieves the second and third section, nut just the second one. What´s wrong here ?
|
|
|
|
|
int nPos = csComboBoxText.Find( '$') + 1;
csAnsprech = csComboBoxText.Mid( nPos , csComboBoxText.GetLength()- csComboBoxText.Find( '$',nPos ));
nave
|
|
|
|
|
Hello RadioOpa,
try this:
<br />
int i =0;<br />
while(i < csComboBoxText.GetLength())<br />
{<br />
if(csComboBoxText.GetAt(i) == '$')
{<br />
i++;
while(csComboBoxText.GetAt(i) != '$')
{<br />
csAnsprech += csComboBoxText.GetAt(i);<br />
i++;
}<br />
}<br />
i++;
}<br />
i hope that helps you!
regards
break;
P.S. that sample from nave ist very good, i want just to show you another way without Find-Functions to extract a part of string
-- modified at 2:55 Tuesday 21st March, 2006
|
|
|
|
|
Many thanks, both ways solving the problem are excellent.
I changed code as follows:
iFirstSection = csComboBoxText.Find( '$'); // Find first '$'
iSecondSection = csComboBoxText.Find( '$', iFirstSection +1); // Find second '$'
csFirma = csComboBoxText.Mid( 0, iFirstSection); // Get first string section
csFirma.TrimRight( ' ');
csOrt = csComboBoxText.Mid( iFirstSection +1, iSecondSection - iFirstSection); // Get second
csOrt.TrimRight( ' ');
csFirmaID = csComboBoxText.Mid( iSecondSection +1); // Get last section
|
|
|
|
|
|
Hi all
I have a char array
char codenew[12];
codenew[0]='\0';
How to convert it into a CString ?
Any help plz ?
redindian
|
|
|
|
|
char codenew[12];
strcpy(codenew,"Blah");
CString TempString = codenew;
|
|
|
|
|
hi
Thanks
Now i am facing another problem
char autocode[12];
stycpy(autocode,"1234");
CString csBuffer ="1234";
if(strcmp(autocode,(char*)(csBuffer.GetBuffer(csBuffer.GetLength()))))
{
csBuffer.ReleaseBuffer();
return TRUE;
}
Now , at csBuffer.ReleaseBuffer() ..it crashes ..
I dont understand why ...
I feel strcmp still holds the memory returned by csBuffer.GetBuffer right ?
can u help me solve it ?
redindian
|
|
|
|
|
Why don't you just do this?
char autocode[12];
strcpy(autocode,"1234");
CString csBuffer ="1234";
if(strcmp(autocode,(LPCTSTR)csBuffer)) return TRUE;
A CString is freed when it goes out of scope so you (normally) don't have to.
OT:
Why should it return TRUE for a difference between autocode and csBuffer?
|
|
|
|
|
dharani wrote: char autocode[12];
stycpy(autocode,"1234");
CString csBuffer ="1234";
if(strcmp(autocode,(char*)(csBuffer.GetBuffer(csBuffer.GetLength()))))
{
csBuffer.ReleaseBuffer();
return TRUE;
}
You are going a long, long way just to compare strings. Note that you are not doing anything specific to CString s, so it is a waste to use one. But since you have one, use its Compare(...) method:
CString csBuffer = _T( "1234" );
if( !csBuffer.Compare( _T( "1234" ) ) )
{
}
else
{
}
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Have you tried this
char c[10] = "My Array";
CString str;
str.Format("%s",c);
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
as Cedric explained with a code sample, the CString class provides an operator = (const TCHAR*) which allows you to assign directly a CString with a char*...
char* codenew = "hello";
CString str = codenew;
|
|
|
|
|
My code is followed, it's good to run in a general WinApp,but in a windows service,it doesn't work. Does anybody give me a hand?
void CLoadDlg::StartUpFederate(CString federatePath,CString sCommandLine)
{
char cCommandLine[MAX_PATH];
PROCESS_INFORMATION pi;
STARTUPINFO si;
memset(&si,0,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags |= STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
char CurrentDir[MAX_PATH];
//GetCurrentDirectory
GetCurrentDirectory(MAX_PATH,CurrentDir);
//SetCurrentDirectory
SetCurrentDirectory(federatePath);
::strcpy(cCommandLine, sCommandLine);
SECURITY_ATTRIBUTES sa;
SECURITY_DESCRIPTOR sd;
InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd,TRUE,NULL,FALSE);
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;//TRUE;
sa.lpSecurityDescriptor = &sd;
BOOL ret = CreateProcess(NULL, // pointer to name of executable module
cCommandLine, // pointer to command line string
NULL, //&sa,//// process security attributes
NULL,//&sa,// // primary thread security attributes
FALSE,//TRUE, //FALSE,// handle inheritance flag
0, //CREATE_NEW_CONSOLE// creation flags //HIGH_PRIORITY_CLASS
NULL, // pointer to new environment block
NULL, // pointer to current directory name
&si, // pointer to STARTUPINFO
&pi); // pointer to PROCESS_INFORMATION
//SetCurrentDirectory
SetCurrentDirectory(CurrentDir);
}
|
|
|
|
|
There is many url protocols such as "rtsp" "mms" "http" "ftp" "svn" and so on.
Now, I want to establish my own protocol. For example:"mypro"
How to do it?
Thanks.
|
|
|
|
|
Luckily, I found the answer at "Registering an Application to a URL Protocol" of MSDN.
|
|
|
|
|
hello frds ,
i stuck at the point of filling pixels in bitmap file....
Problem:
i have to genarate a .bmp file thas why i write a BITMAPFILEHEADER and BITMAPINFOHEADER structure in file.
now i face difficult to fill colors in that file.
i am not getting what is palatte and rgb quad.
I directly put the value of rgbquad in file like
fwrite(&rquad,sizeof(rquad),1,image);
it doent work!!!
reply
thanks in advance !!
Rahul here
|
|
|
|
|
Hi rahul.shendurnikar,
Do you want to create bitmap and draw color on the bitmap
|
|
|
|
|
hello frds ,
i stuck at the point of filling pixels in bitmap file....
Problem:
i have to genarate a .bmp file thas why i write a BITMAPFILEHEADER and BITMAPINFOHEADER structure in file.
now i face difficult to fill colors in that file.
i am not getting what is palatte and rgb quad.
I directly put the value of rgbquad in file like
fwrite(&rquad,sizeof(rquad),1,image);
it doent work!!!
reply
thanks in advance !!
Rahul here
|
|
|
|
|
What does __RPC_FAR do?
typedef /* [unique] */ IDispatch __RPC_FAR *LPDISPATCH;
What does this signify?
Thanks for helping!
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Save My Soul - (SMS) wrote: What does __RPC_FAR do?
typedef /* [unique] */ IDispatch __RPC_FAR *LPDISPATCH;
What does this signify?
16 bit environments used to have near and far pointers, and __RPC_FAR used to indicate a far pointer. It is provided for compatibility reasons, it is defined as nothing.
Nibu thomas
Software Developer
|
|
|
|
|
Hi all,
How can I change the font of the dialog dynamically. I have tried SetFont from OnInitDialog() function.But it dosen't work.
Please help me
Thanks in advance
Naveen.R
nave
|
|
|
|
|
1. place the following string somewhere in your "stdafx.h" file:
#include <afxpriv.h>
2. override DoModal() function in your dialog class:
int CSampleDialog::DoModal()
{
CDialogTemplate dlt;
int nResult;
// load dialog template
if (!dlt.Load(MAKEINTRESOURCE(CSampleDialog::IDD))) return -1;
// set your own font, for example "Arial", 10 pts.
dlt.SetFont("Arial", 10);
// get pointer to the modified dialog template
LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);
// let MFC know that you are using your own template
m_lpszTemplateName = NULL;
InitModalIndirect(pdata);
// display dialog box
nResult = CDialog::DoModal();
// unlock memory object
GlobalUnlock(dlt.m_hTemplate);
return nResult;
}
It may be reasonable to choose a font for your dialog box according to user-specified schemes (those in Control Panel / Display / Appearance). Unfortunately I was unable to find any simple ways to get font settings for the dialog boxes. A possible alternative is to use font settings for icon titles and some related controls (like tree and list controls), that can be retrieved by SystemParametersInfo() function. Here is a simple procedure that returns the face name and the size in points for this font:
void GetSystemIconFont(CString& strFontName,int& nPointSize)
{
LOGFONT lf;
// get LOGFONT structure for the icon font
SystemParametersInfo(SPI_GETICONTITLELOGFONT,sizeof(LOGFONT),&lf,0);
// getting number of pixels per logical inch
// along the display height
COLOR="#990000">
HDC hDC = ::GetDC(NULL);
int nLPixY = GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(NULL,hDC);
// copy font parameters
nPointSize = -MulDiv(lf.lfHeight,72,nLPixY);
strFontName = lf.lfFaceName;
}
Ashok Reddy
|
|
|
|
|
1. place the following string somewhere in your "stdafx.h" file:
#include <afxpriv.h>
2. override DoModal() function in your dialog class:
int CSampleDialog::DoModal()
{
CDialogTemplate dlt;
int nResult;
// load dialog template
if (!dlt.Load(MAKEINTRESOURCE(CSampleDialog::IDD))) return -1;
// set your own font, for example "Arial", 10 pts.
dlt.SetFont("Arial", 10);
// get pointer to the modified dialog template
LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);
// let MFC know that you are using your own template
m_lpszTemplateName = NULL;
InitModalIndirect(pdata);
// display dialog box
nResult = CDialog::DoModal();
// unlock memory object
GlobalUnlock(dlt.m_hTemplate);
return nResult;
}
It may be reasonable to choose a font for your dialog box according to user-specified schemes (those in Control Panel / Display / Appearance). Unfortunately I was unable to find any simple ways to get font settings for the dialog boxes. A possible alternative is to use font settings for icon titles and some related controls (like tree and list controls), that can be retrieved by SystemParametersInfo() function. Here is a simple procedure that returns the face name and the size in points for this font:
void GetSystemIconFont(CString& strFontName,int& nPointSize)
{
LOGFONT lf;
// get LOGFONT structure for the icon font
SystemParametersInfo(SPI_GETICONTITLELOGFONT,sizeof(LOGFONT),&lf,0);
// getting number of pixels per logical inch
// along the display height
COLOR="#990000">
HDC hDC = ::GetDC(NULL);
int nLPixY = GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(NULL,hDC);
// copy font parameters
nPointSize = -MulDiv(lf.lfHeight,72,nLPixY);
strFontName = lf.lfFaceName;
}
Ashok Reddy
|
|
|
|
|
Thanks ashok..it works.
Should i have to overide the Create() function so that the font will change when dialog is created as Modless?
nave
|
|
|
|