|
Then that is a compiler specific detail. It's not in the standard! The Visual C++ compiler for instance, initializes all members to seemingly "garbage" values in debug mode. The garbage however, is useful, as it gives the programmer a good hint on what is wrong (uninitialized variables are easily detected). IIRC, the compiler initializes member variables with byte strings containing repeating the pattern 0xcd . Members of deleted objects are given 0xfe .
I wouldn't rely on this behaviour, because it's probably subject to change with any release, and it is not portable.
--
Keep talking! You're the fool, I'm the preacher.
|
|
|
|
|
Ye , maybe it's compiler dependant...
But then do you know exactly the difference between
CClassX* pC = new CClassX();
CClassX* pC = new CClassX;
i don't think that there is no difference at all
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Hello
I want to record sound from Sound card to memory(buffer).
That sound is generated by people using microphone.
How can I decide it?
I am not have any Idea now.
If you have any suggestion, help me pls?
Thank you so much for you help.
Thank you
|
|
|
|
|
There are articles about that on CodeProject!
Don't try it, just do it!
|
|
|
|
|
I used the code bellow to Initialize COM. but It always says that Establishes the spatial documents is defeated when the program run.
I used app wizard to create a MDI project Test(vc6).
I only changed the base class of CTestView into CMyView. CMyView is my own definition.It was derived from CListView.
Code in InitInstance:
HRESULT hres;
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres))
{
CString csErr;
csErr.Format( _T("Failed to initialize COM library. Error code = %d"),hres);
AfxMessageBox(csErr);
return FALSE;
}
hres = CoInitializeSecurity(NULL, -1, NULL, NULL,
RPC_C_AUTHN_LEVEL_CONNECT,
RPC_C_IMP_LEVEL_IDENTIFY,
NULL, EOAC_NONE, 0
);
if(FAILED(hres))
{
AfxMessageBox(_T("CoInitializeSecurity Failed"));
}
and Code in ExitInstance:
CoUninitialize();
for a test,you must define _WIN32_DCOM
Please,give me a help. Thank you very much.
|
|
|
|
|
how to copy a BSTR to char array? :-?
char sz[20];
BSTR *bstr;
[i tried the below code, but didn't work]
strcpy(sz,W2T(bstr));
Err:
D:\PROJ\CTI MFC FW\ATL53\AT53.cpp(16) : error C2065: '_lpw' : undeclared identifier
D:\PROJ\CTI MFC FW\ATL53\AT53.cpp(16) : error C2440: '=' : cannot convert from 'unsigned short ** ' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\PROJ\CTI MFC FW\ATL53\AT53.cpp(16) : error C2065: '_convert' : undeclared identifier
thanks
v
|
|
|
|
|
You need to add
USES_CONVERSION;
somewhere in your source. See MSDN for details.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Use
BSTR bstrName=::SysAllocString(L"prasad");
char *charPointer=new char[256];
WideCharToMultiByte(CP_OEMCP, 0, bstrName, -1, charPointer, 256, NULL, NULL );
Alternatively you can use wrapper _bstr_t
_bstr_
|
|
|
|
|
oops! sorry i'm confused a bit.. that removal of * didn't work. .. sorry. i'll try your way now
|
|
|
|
|
I'm using
USES_CONVERSION;
strncpy(sz,OLE2T(bstr), 25);
please note that is not secure to use strcpy, due buffer overflow attacks.
Thats why you should use strncpy
|
|
|
|
|
Hi, I notice many 3D CAD systems have treeviews on top of the 3D view of the drawings(rendered by OpenGL or Direct3D), and I would like to know how it is being done.
I believe the pixels are blitted from the bitmap of the treeview onto the framebuffer of the 3D view, and this is the part I am familar with.
What I don't know is whether the treeview is just the standard treeview in Windows, and how to program it so that the actual treeview is invisible, and how all the mouse clicking stuff works.
Does anyone have any idea?
TIA
|
|
|
|
|
This is a simple code to insert some string at
a given cursor position for CEdit
CPoint point;
::GetCursorPos( &point );
m_ScriptWin.ScreenToClient(&point);
int CharPos = m_ScriptWin.CharFromPos( point );
m_ScriptWin.SetSel(CharPos,CharPos,TRUE);
m_ScriptWin.ReplaceSel(" ***This is the inserted text*** \r\n");
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
this is one more method but havent tested it
POINT point;
::GetCursorPos( &point );
m_Edit.ScreenToClient(&point);
int CharPos = m_Edit.CharFromPos( point );
WORD charind = LOWORD(CharPos);
CString s;
m_Edit.GetWindowText(s);
s = s.Left(charind)+"mystring"+s.Right(s.GetLength()-charind);
m_Edit.SetWindowText(s);
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
|
yeh actully
i need to get the MAC address from
the user but , i didnot find any
such control for it .
So i was trying to create a control
which will get the string for the
user and returns an array of six
string containing the parsed MAC add
Something like the IP Address control.
If u know any link from were i can get
the control for MAC address do post me.
Thanks for you concern
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
One way is with Netbios() . Another way is with GetAdaptersInfo() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
V
|
|
|
|
|
I have a small problem were i need to
change the back color of the CEdit & CStatic
control , is there any simple code for the
same.
Yeh and how can i change the font color in
CEdit.
thank u
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
use ON_WM_CTLCOLOR message
|
|
|
|
|
Cool! Learn something new everyday!
I suppose this is faster (performance wise) than use a derived class from CEdit etc and doing DrawItem ect. And much simpler.
|
|
|
|
|
first of all Thank u for your reply
I am using a MFC application
were i am displaying a Dialogbox
were i have a CEdit control .
Which is suppose to change the colour
when a user enters invalid entry (non-numeric)
I dont wont to touch the base class (CEdit)
or nor want to derive new class from it .
ON_WM_CTLCOLOR
I need some solution i have tried to get the
"Device Context "of the edit box but it could
not print inside rather it printed outside the
Edit box .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
first of all Thank u for your reply
I am using a MFC application
were i am displaying a Dialogbox
were i have a CEdit control .
Which is suppose to change the colour
when a user enters invalid entry (non-numeric)
I dont wont to touch the base class (CEdit)
or nor want to derive new class from it .
ON_WM_CTLCOLOR
I need some solution i have tried to get the
"Device Context "of the edit box but it could
not print inside rather it printed outside the
Edit box .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Use that message and handle it, amin, it is very easy. Do a search on the web you will get an example in msdn. I just spent 5 min doing that and get a test case working.
As to the number thing, you should be able to config the edit ctrl to accept number only. In the code, you may be able to use something like this:
DDV_MinMaxLong(...) <-- check reference how to use it. It's been a while since I last use them.
What u will get is if user inputs an invalid entry, a messagebox will come up telling him so. You do not even need to change the CEdit color to let him know.
|
|
|
|
|
Thank you very much
i have got the code working now
The client requirement was to change the colour of the
dialog box so i had to do that .
just pasted the code for other programers
Example<br />
<br />
<br />
HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) <br />
{<br />
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<br />
<br />
if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)<br />
{<br />
pDC->SetTextColor(RGB(255, 0, 0));<br />
<br />
pDC->SetBkMode(TRANSPARENT);<br />
<br />
hbr = m_brush;<br />
}<br />
<br />
return hbr;<br />
}<br />
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|