Wednesday, July 14, 2010

Some varialbes in Visual C++

1.
LPCTSTR stands for Long Pointer Constant String.
Basically consider LPCTSTR a (char*).. theres a little more to it, but basically:
LPCTSTR s = "Hi!"

and

char *s = "Hi!"

are the same


2.
CWnd: to create Window. Header: afxwin.h
You create a child window in two steps. First, call the constructor
CWnd to construct the CWnd object, then call the Create member function to
create the child window and attach it to the CWnd object.

3.
UINT is an unsigned (meaning it doesn't hold negative values) integer.

4. _T(" ") for Unicode, Unicode can be disabled from project property.

5. use delete to prevent memory leakage


#include <iostream>
using namespace std;

int main(){

int *i=new int(1); //*i=1


cout<<"*i="<<*i<<endl;//*i=1
//defines a pointer to an array of 3 ints
int *j=new int[3];

cout<<"*j="<<j[0]<<endl;
delete  i;//delete pointer to prevent memory leakage
delete [] j;//delete pointer to array

return(0);
}


6. CDC class: Defines a class
The CDC object provides member functions for working
with a device context, such as a display or printer, as well as members
for working with a display context associated with the client area of a
window.s of device-context objects.
example using CDC::TextOut() method:
void CExoView::OnDraw(CDC* pDC)
{
CExoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

pDC->TextOut(50, 42, "Johnny Carson", 13);

}
Header: afxwin.h


No comments:

Post a Comment