|
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
|
|
|
|
|
Yes..
Override create for modeles dialog.
Try that and revert me back whether it works fine or not.
Thanks & Regards,
Ashok
|
|
|
|
|
Halo Naveen,
I think you have not updated your dialog data after setting the font. After you finish setting the font in dialog, do UpdateData(0); If the problem is something else, I could give you a small sample code snippet on how to set a font. Please let me know of anything.
Regards,
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
Can u show me the sample? I have tried updateData(0). it dosen't work
nave
|
|
|
|
|
Please send me the site addresses for changing the skin.
Is there any possibility to change the skin through code?
Please reply ASAP.
Thanks & Regards,
Ashok.
Ashok Reddy
|
|
|
|
|
Skinning[^] a dialog.
Nibu thomas
Software Developer
|
|
|
|
|
|
|
what I know is the path of the file.
and I want to adjust the size of the image on the dialog, too.
Thank you very much!!!
-------------------
I am learning C++ and English
|
|
|
|