|
Flace wrote:
a google search on "_tcsinc" yielded only 356 results!
You should also search for CharNext , the win32 API equivalent of the C runtime function _tcsinc .
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
okay, that gives more results. perhaps it is more known to people than the _tcsinc.
Do you use either of these in your programs?
|
|
|
|
|
I missed an important question in the previous post:
if you dont use _tcsinc, you are either assuming the string have 1 byte characters or your program will go wrong someday. And if you assume your char is 1 byte, then using _TCHAR doesnt make sense. You can use just the char as well. What do you folks say?
|
|
|
|
|
If you use TCHAR, you are IMPLYING your string can be UNICODE if a UNICODE build is made. If your string must ABSOLUTELY be 'single byte characters' then use 'char' and if it must absolutely be UNICODE, then use wchar_t or WCHAR. You can potentially convert back and forth with MultiByteToWideChar and WideCharToMultiByte.
If you want your 'single-byte-character' processing to be internationalized, then at least compile for MBCS and use the 'mbs' for every hard-coded 'char' string and the '_tcs' functions on every TCHAR string. You get BIZARRE results if you hard code to an 'mbs' function against a TCHAR string and then commpile for UNICODE. Now you would be passing a wide-character string to a function expecting multi-byte character string.
Summary:
char -> use str or (preferably) mbs functions
TCHAR -> use tcs functions (compile either way)
WCHAR or wchar_t -> use wcs functions
|
|
|
|
|
Flace wrote:
So how many of you use _tcsinc?
I don't use any of the _tcsxxx() functions. For what I'm working on, there is no need.
Flace wrote:
a google search on "_tcsinc" yielded only 356 results!
What about those folks that do use it but don't publish their code?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
What about those folks that do use it but don't publish their code?
You are right, google search doesnt indicate that people do not use it. i was only looking at how people have used it, through google.
|
|
|
|
|
For starters, our codebase is not accessible by Google... :->
There is also CharNext to consider.
There is also _mbsinc to consider.
I agree, however, that the code is more portable to other data formats if the _tcsinc is used instead.
We have a mixcture of ALL of the functions, unfortunately.
Newer (and overhauled) code is using _tcsinc
|
|
|
|
|
|
Flace wrote:
All projects in VC6 seem to have MBCS defined by default.
Always the first thing i change.
I always set to either UNICODE or nothing.
I always explicitly use unicode or ansii string class'/functions.
Not a big fan of this whole 'it may be ansii, it may be unicode, it may be mb'.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
class CEncoderView is a MDI's view class. class CBMWin which derived from class CWnd is the subwindow of class CEncoderView.
I want to save the view as a DIB, so that I firstly DoModal a dialog for getting the DIB file's path. then I send a message MY_SAVEWHOLE which is handled in DefWindowProc to save the view as a DIB file.But I find the dialog is also appeared in the DIB file.
In order to clear the dialog, I invalidate the whole desktop befor saving the view shown as step 1 in the source code below. At this time, there are only the subwindow frames be showed in the DIB. they client rect is empty,because they did't redraw themselves.
In step 2 shown in the source code below, I get messages from the message queue. I want to save the view after all of its subwindows have send a message MY_REDRAW to it. But I find that the function GetMessage can't retrieve message MY_REDRAW at label A in the source code below. Meanwhile, I can retrieve the message MY_REDRAW in the function DefWindowProc at label B which shown in the source code below.
How the message be dispatch in the window?
#define MY_SAVEWHOLE WM_APP + 2 //save a view window as a file
#define MY_REDRAW WM_APP + 3 //have redrawed a subwindow
void CEncoderView::OnExportimage()
{
CExportImageDlg exportidlg( this );
int nRet = -1;
nRet = exportidlg.DoModal();
if (( nRet == -1 ) || ( nRet == IDABORT ))
{
AfxMessageBox( "Dialog box could not be created!");
return;
}
if ( nRet != IDOK )
{
return;
}
//added in step 1
//redraw all windows
::InvalidateRect( NULL, NULL, FALSE );
//end of added in step 1
//added in step 2
//the number of subwindows whose type isCBMWin
int iRedrawedSubWin = 0;
MSG msg;
int bRet;
//if all of the subwindows had redrawed themselves
//then save the view as a DIB
while(( iRedrawedSubWin < iSubWinNum ) &&
((bRet = ::GetMessage( &msg, NULL, 0, 0 )) != 0))
{
//can't retrieve message MY_REDRAW at this point
if ( msg.message == MY_REDRAW )
{
//never execute,can't retrieved message MY_REDRAW
label A: iRedrawedSubWin++;
}
if (bRet == -1)
{
break;// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
//end of added in step 2
::SendMessage( m_hWnd, MY_SAVEWHOLE, ( WPARAM )( &exportidlg.m_CSFileRoute ), NULL );
}
LRESULT CEncoderView::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
CBMWin* pChildWnd = NULL;
int iRetValue;
PBITMAPINFO pBitmapInfo = NULL;
switch( message )
{
case MY_SAVEWHOLE:
iRetValue = Win2DIB( this, &pBitmapInfo);
if ( iRetValue != ERR_OK )
{
return 0;
}
SaveDIBFile( pBitmapInfo, ( CString* )wParam );
free( pBitmapInfo );
return 0;
case MY_REDRAW:
//when subwindow redraw,this message can be retrieved
label B: iRetValue = 0; //no mean.
}
return CView::DefWindowProc(message, wParam, lParam);
}
void CBMWin::OnPaint()
{
CPaintDC dc(this); // device context for painting
RECT rect;
GetClientRect( &rect );
//draw a DIB on the client rect
StretchDIBits( dc,
0, 0, rect.right, rect.bottom,
0, 0, ...);
//tell the prarent window CEncoderView it has redrawed itself
::SendMessage( GetParent()->m_hWnd, MY_REDRAW, NULL, NULL );
}
andy
|
|
|
|
|
How to fix (custom ActiveX)control size in design time.
I am using MFC ActiveX ControlWizard.
Please help me.
Thanks
David Park
|
|
|
|
|
Hello,
I am currently trying to change from VB .Net to VC++ .Net.
I am trying to take information from a KeyUp event in the main form (form1), and put the KeyData into label1->Text .
Here is my code:
private: System::Void Form1_KeyUp(System::Object * sender, System::Windows::Forms::KeyEventArgs * e)
{
label1->Text = e->KeyData;
}
However, it returns me the error saying that "c:\...\TestingC++\Form1.h(96): error C2664: 'System::Windows::Forms::Control::set_Text' : cannot convert parameter 1 from 'System::Windows::Forms::Keys' to 'System::String __gc *'"
What should I do to correct this error?
Any help will be greatly appreciated,
Programmer2k4
My sig:
"And it is a professional faux pas to pay someone else to destroy your computer when you are perfectly capable of destroying it yourself." - Roger Wright
I now use my CodeProject Blog!
Most recent blog post: March 24
|
|
|
|
|
That is because the KeyValue return int.
[C++]
public: __property int get_KeyValue();
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Is there any way, given a certain font, to know if a specific character will be able to be rendered properly or will be displayed as a "I-don't-know-how-to-draw-this" box.
I want to display some Japanese text, but only if the font is going to be able to render it properly.
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin
Awasu 2.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Hi,
I want to change the size of array in run-time without loosing the elemnts of array.
Best wishes,
Thanks.
|
|
|
|
|
hum, I really wonder that you don't know C++ quite well.
i already post for you something about operator new .
if you want to change the size of an array (of course, without loosing its content), you allocate a new array (with the new size), you copy the existing datas from the previous array, you delete the old array...
that's quite simple, but if you have to perform lots of operation of this type on an array, you'd better have a look at the STL containers, especially list<> and vector<>
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Look at realloc, it does just this. If you want to change the array size very offen, you better use stl vector. But unfortunately, stl with vc++ requires a dll(I forgot the name) to be present on the system, so you have to distribute it.
|
|
|
|
|
realloc() is not "re-entrant" (i'm not sure about how to say this in english. this C function is to avoid. Moreover, we have powerful tools in the Standard C++ Library that are optimized to do plenty of arrays' size modifications...
Another thing : vector<> do only need <VECTOR> header to be included in the source, but no DLL at all...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
STL requires msvcp60.dll which, ironically, is not present on a freshly installed Win2k or WinXP.
|
|
|
|
|
strangely, i never encountered the problem...
so, you'll answer, oh, that's because i've just said "on a freshly installed Win2k or WinXP". yep, BUT, i already programmed on "freshly installed WinXP" (on VMWare if you know) cause my own PC was running under Win2K... the only problem i had is that the Bluetooth functions I needed were not present on the pack I had of MS Visual Studio .NET, but no problem with vectors...
i can't explain more, i don't think i have a ghost that installed "msvcp60.dll" on my system when i was watching at it... :->
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
MS Visual Studio .NET is the ghost in your case.
Its just my experience, believe it or experience it yourselves
|
|
|
|
|
it is a program of MSDN , which i have written in console win32 application because in win32 applicaiton it was also giving problems.It gives an error that SetDICreateDeviceInfoList() does not take 7 parameters....Plz help me out i also used debug mode still i was unable to derive the hardware list
#include <windows.h>
#include <setupapi.h>
#include <stdio.h>
DWORD Err;
HDEVINFO DoDeviceEnum( GUID InterfaceClassGuid)
/*
Routine Description:
Retrieves the device information set that contains that contains
the devices of the specified class.
Parameters:
InterfaceClassGuid - The interface class GUID.
Return Value:
If the function succeeds, the return value is a handle to the
device information set.
If the function fails, the return value is zero.
*/
{
HDEVINFO DeviceInfoSet;
HDEVINFO NewDeviceInfoSet;
// Create a device information set that will be the container for
// the device interfaces.
DeviceInfoSet = SetupDiCreateDeviceInfoList(NULL, NULL);
if(DeviceInfoSet == INVALID_HANDLE_VALUE) {
Err = GetLastError();
printf( "SetupDiCreateDeviceInfoList failed: %lx.\n", Err );
return 0;
}
// Retrieve the device information set for the interface class.
NewDeviceInfoSet=SetupDiGetClassDevsEx( InterfaceClassGuid,NULL,NULL,DIGCF_PRESENT | DIGCF_DEVICEINTERFACE,DeviceInfoSet,NULL,NULL);
if(NewDeviceInfoSet == INVALID_HANDLE_VALUE)
{
Err = GetLastError();
printf( "SetupDiGetClassDevsEx failed: %lx.\n", Err );
return 0;
}
return NewDeviceInfoSet;
}
int main(int argc, TCHAR* argv[])
{
DoDeviceEnum(NULL);
return 0;
}
|
|
|
|
|
i included the windows.h,setupapi.h,stdio.h
i want the computer to enumerate the hardware devices like
mouse,key board, NIC etc....
thanks
|
|
|
|
|
search in the forum, this question has been asked few days ago...
(maybe it was you )
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|