|
<<< In the name of GOD >>>
Hi.
What is different between CFile and CArchive for write and read from file ?
Hadi Rezaie
|
|
|
|
|
CFile just provides basic read and write operations. CArchive uses a CFile to add serialization capaibility to MFC and to use the inserter/extractor operators (<< and >>)
|
|
|
|
|
<<< In the name of GOD >>>
Hi.
Please explain to me rules about put names for variables.
Understand ?!!!
Hadi Rezaie
|
|
|
|
|
You mean Hungarian notation ? Basically the standard way of doing things is to preface a member variable with m_, a global ( globals are evil though, so you have none, right ??? ) with g_ and then the first letter or two tell you the type of the variable.
i.e.
int m_iMyInteger;
CString m_szMyString;
But ultimately, these rules only benefit if a team all follow them - in other words, if you work alone, what convention you use is up to you.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
<<< In the name of GOD >>>
Hi.
Please write example with full explain about HGLOBAL For allocate memory.
Does HGLOBAL == malloc ?
Hadi Rezaie
|
|
|
|
|
From MSDN
HGLOBAL – a special case but still (mostly) transparent
HGLOBAL is different from GDI and USER handles discussed above in that it can either be a 32b handle or an actual pointer (32b or 64b depending on the platform). An HGLOBAL is created as a handle when GMEM_MOVEABLE flag is used in GlobalAlloc API, otherwise it is created as a pointer.
Accordingly, the application writer may have the following situations:
The HGLOBAL in question comes as a handle – in this case the choices are the same as for the GDI and USER handles described above.
The HGLOBAL in question comes as a pointer and …
it was sent over the wire as an HGLOBAL - do nothing, ole32.dll code handles situation transparently
it was sent over the wire as a DWORD – you do have a problem, you need to solve it as discussed for pointers
you are designing a new interface, in order of preference: use HGLOBAL as the types of argument, use context handles or use a LONG64 argument to hack through.
To recap, if your app sends HGLOBAL as an HGLOBAL, you don’t need to do anything as ole32.dll code marshals and unmarshals it transparently.
Also note that HLOCAL is a typedef on HGLOBAL.
A personal note - DON'T USE MALLOC. Use new/delete to allocate memory, that is what they are for. malloc/calloc/realloc are left over from C. If I had my Stroustrup handy I'd give eloquent reasons not to use them, but I do not.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Thanks a loooot.
It was FULL reply.
Now i have two questions.
Q1. What is your MSDN version ?
Q2. I think that new/delete is for allocate memory from stack memory.
So, malloc ? stack memory or ... ?
Hadi Rezaie
|
|
|
|
|
<<< In the name of GOD >>>
Hi.
I want to change text color with CColorDialog.
I have little problem, becuase for changing color, i must
click on edit box and then color will change ...
It mean when i click on OK button,
text color won't change, and i must click on the edit box
to change color.
void CTestglobalDlg::OnOK()
{
CColorDialog m_ColorDlg;
if(m_ColorDlg.DoModal() == IDOK)
{
Ced = m_ColorDlg.GetColor();
}
}
HBRUSH CTestglobalDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor == CTLCOLOR_EDIT)
{
pDC->SetTextColor(Ced);
}
return hbr;
}
Ced is member variable:
COLORREF Ced = RGB(0,0,0);
You can test it.
I want to change color with out click on edit box.
Please help me ...
Hadi Rezaie
|
|
|
|
|
The problem you have is that the window has changed it's property, but has not been redrawn. Any CWnd derived class has a function called Invalidate which tells the window it needs to be redrawn. It takes a BOOL, and if it is true, the control calls OnEraseWnd first, i.e. it will go blank then redraw, causing flicker. So to fix your problem, once you set the colour, go
Invalidate(false);
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
<<< In the name of GOD >>>
Hi all.
Q1.
Does for use of STL have any header file in VC++ ?
Or we can use of STL with out any header ?
Q2.
Which is true, for use of below function ?
template <class t="">
T Add(T a, T b){return(a + b);}
1.
int result = Add<int>(10,10);
2.
int result = Add(10,10);
Which is true ???
Q3.
if i have two template: template <class t,="" class="" a="">
How can use of two template T,A for write function ?
Please write example with full explain.
Q4.
What mean template <int i=""> ?
Q5.
Please explain to me about CArray.
What mean second parameter of CArray ?
For example:
What is different between:
1.
CArray<int, int=""> my_integer;
2.
CArray<int, int&=""> my_integer;
Best Regards.
Hadi Rezaie
|
|
|
|
|
STL uses many headers, depending on what you need. There is no "stl.h"
for instance, to use strings, you use #include <string>, to use algorithsm, you use #include <algoritm>
The rest of your questions don't make a lot of sense, and based on your other questions, it seems like you need to pick up a good book on C++ and read it before going any further.
|
|
|
|
|
I'm just starting to get into database programming, so bear with me as I stumble through my questions.
I can update and insert and delete records from a database. That I understand pretty easily, what I don't know is how to get the information from the database so that I can display/write to a file/ect the data. How can I pull some information from a database cell so I can look at it with my program?
I'm using VC++ 6.0 and am testing these things with a console app and using a Access database.
What I am looking to do at the moment is to pull the data from a single cell (hard coded which one) and use it in a cout statement. Any help with this would be much appreciated. I would like the command(s) that can do it but a push/shove/kick in the @$$ in the right direction will work just as well. Thanks much.
Quinn
The sun is evil, it denies me Pepsi.
|
|
|
|
|
The only way that I know of to do this is with the use of CDaoRecordset::GetFieldValue, this function will expect a COleVariant as second parameter (first is used to identify the column).
So, for example if you want to read a value found in the first column on the first record in your recordset your code will look like:
CVariant var;
m_recSet.MoveFirst();
m_recSet.GetFieldValue( 0, &var );
Pz
|
|
|
|
|
Hi there,
I am trying to run an exe, but before running it, I would like to find out whether another exe by the same is running on a system or not.
Would anyone here know how I could find such Process information? I would imagine there is a simple way of doing it as Windows NT comes up with its powerful and useful task manager which provides all kind of process information including the actual Process name.
I would appreciate your response.
thanks
|
|
|
|
|
> I would like to find out whether another exe by the same is running on a system or not.
The ToolHelp library may be able to help. Lookup the ::CreateToolhelp32Snapshot function.
Peace!
-=- James.
|
|
|
|
|
I am writing a paint program, which has the primary function of providing texture editing for a 3D system. I am using CopyData to send the path to an image to my paint program, and to send back a message so the 3D package reloads it. I really would love to learn COM but have had no time, such that all I have done is a simple server that returns a string from a list at random and a dialog that uses this to display a string at random. Not exactly rocket science, but my only experiment in learning some ATL before I got too swamped to continue.
Now I am wondering if it would be possible to build an ATL bitmap 'server', in other words to pass in a HBITMAP, sned a message to the other program ( this would go both ways ) which would tell it to change the image refered to in the message by loading the image held in my server. I believe this should be relatively easy, given my usual misplaced optimism, and I'm hoping you guys (and gals, if applicable) could tell me before hand of any problems or potential disasters awaiting me. I am guessing it would work like the clipboard, ie if I pass in a HBITMAP I lose ownership of it, etc. I actually considered using the clipboard but would prefer not to.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hello. I am novice at Visual c++. I would like to excute my program
when client access to my web page. That is, when client access to my web
page, check if my program is installed on client computer or not,
and then, if is, excute my program, and if is not, excute my program
after install my program on client computer. How can I do this??
Please let me know!! My program is big, occupiable CPU because it
is graphic program. Is it possible to make my program to ActiveX, even
if it is so big?? Please let me know.
Thank you...
LJS
|
|
|
|
|
I can answer the second part - we have a 3D package that is pretty big and we have put it into an ActiveX control, so I doubt that will be a problem.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hi!
My Bitmap-Procedure works now without any problems! Thanks
to those who helped me to fix it!!
But there is still no Bitmap on my screen when I start my ShowMyBitmap procedure.
Here is the code:
P.S:Calling my procedures by a a Button which is in the same window as the Bitmap. Is this the mistake?
P.P.S: Using VC++6
-------------------------
void CLastPicDlg::LoadmyPic()
{
m_sFileName = "pic01.bmp";
HBITMAP hBitmap = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
m_sFileName, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION);
m_bmpBitmap.Attach(hBitmap);
MessageBox("Loading:" + m_sFileName, "Loading File");
}
void CLastPicDlg::ShowmyPic(CPaintDC *clientDC)
{
CDC temp;
temp.CreateCompatibleDC(clientDC);
CBitmap* pOldBitmap = (CBitmap*)temp.SelectObject(m_bmpBitmap);
CRect lRect;
GetClientRect(lRect);
lRect.NormalizeRect();
clientDC->StretchBlt(10, 10, (lRect.Width() - 20), (lRect.Height()- 20), &temp, 320, 200, 0, 0, SRCCOPY);
}
void CLastPicDlg::OnLoadbut()
{
LoadmyPic();
}
void CLastPicDlg::OnShowbut()
{
CPaintDC clientDC(this);
ShowmyPic(&clientDC);
}
|
|
|
|
|
You're trying to flip the bitmap ? If not, why are the co-ordinates of the source bitmap reversed ?
I'd suggest doing this:
BITMAP bm;
m_bmpBitmap.GetBitmap(&bm);
then when you stretchblt you can use bm.bmWidth and bm.bmHeight instead of hard coded values.
I'd also check the hBitmap for NULL to make sure it is OK, and check the BOOL return from StretchBlt in order to narrow down your problem, but I'm a little nervous about your source co-ordinates - change them to 0,0,bm.bmWidth,bm.bmHeight and then experiment. I remember the flipping of images being a little different to what the MSDN saya but I don't recall the details, so I'd get it showing first, then try to flip it. I think you're grabbing 0 pixels across and down starting from 320, 200.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Greetings Programs,
I've hit an interesting error when using threads and timers in my latest project. If I execute a new thread from one class calling a function of another class like so:
_beginthread(pPointer->IInitializeMonitor, 0, NULL);
I recieve the following error:
Y:\smtpmon\smtpmon.cpp(364) : error C2664: '_beginthread' : cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void *)'
Similarly, if I call a Timer Callback function from within it's own class, such as:
bSuccess = SetWaitableTimer(
hTimer, // Handle to the timer object.
&liDueTime, // When timer will become signaled.
m_iInterval*1000, // Periodic timer interval of X seconds.
TimerAPCProc, // Completion routine.
NULL,
FALSE ); // Do not restore a suspended system.
I recieve the following error:
Y:\smtpmon\smtpcom.cpp(57) : error C2664: 'SetWaitableTimer' : cannot convert parameter 4 from 'void (void *,unsigned long,unsigned long)' to 'void (__stdcall *)(void *,unsigned long,unsigned long)'
I'm sure that I'm missing something simple, but I just can't figure out what it is. Any help would be greatly appreciated.
Rhoam
|
|
|
|
|
yes, it's simple:
C != C++
you can only use plain C functions (or static C++ member functions) as the callback or thread proc.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
|
it is somebody ho know more about gantt in vc++?
bogdan
|
|
|
|
|
|