Its something about DAO can’t initialize, the error code is AFX_DAO_ERROR_ENGINE_INITIALIZATION , I can recall that we have to put something like initialization function before starting using DAO, is that right, but I can’t remember the syntax
It throws the same exception when I tried to do so,
I know that DAO is not working well in multithreaded environment, but I heard that this is fixed if I turn my DLL to UNICODE version, which I‘ve done, but still not working.
i am using the code below which i copied from somewhere for an application which uses a vertical scrollable child. now i realise my application need a horizontal scroll also.....can i use back the same code ?
void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
int nMaxPos = m_rcOriginalRect.Height() - m_nCurHeight;
if (m_nScrollPos >= nMaxPos)
there are several way to calc it. it depends on what kind of coordinate system you are using. you have to consider whether absolute or relative, whether integer or float, whether zoom in/out feature will be added or not, and etc.
scrollbar control has its absolute coordinate like 'range' like 0~255 or 0~32767. this is physical coordinate. So your logical coordinate in your mind has to be matched to physical coordinate as correct ratio. for example, if the maximum size of logical map is 327680 pixel and physical scroll range is 0~32767, then current pixel position to draw to screen has to be scrollbar position * 10. so if the scrollbar position is 16384 (1/2 of range), then current map position is 16384 * 10 = 163840.
and you also have to consider view window width, height.
anyway, scroll bar controling is a little complex and i'd like to suggest you to research formal way. there are lectures on the internet.
>hello i want to make an overload of the assignement operator in C++ but it generated this
>error ... someone help please
>this is the code:
>friend CMot& operator = (const CMot); --> in CMot.h
>CMot& operator = (const CMot m) --> in CMot.cpp
It's been a while since I've dealt with this but my guess would be that "friend" indicates an external function or class. Since the only entitity you're dealing with is the object itself, both as object and returned value, you don't need the "friend" designation. It puts it outside the class.
I have never seen anyone post a joke/game message so I'm going to now. Here are three games that I have written. There on my web site and I know there not that great but I want to shere them any way. You probably will not be interested in "grace game" but the other two may be kinda neat. Any comments are welcome.
"To an optimist the glass is half full.
To the pessimist the glass is half empty.
To the programmer the glass is twice as big as it needs to be."
GC13: "Mature-Ages 16 and up. 'your mature, right?'"
FARGORE: "no, but I am over 16."
in the case u describe it is used to pass the object by address or by reference.
It will depend on the signature of the called function. If I'm not mistaken this
function GetWindowRect expects a pass by address (a pointer) because its
based on the an API call which is written in plain C where there are no references
int iValue = 3;
int* pValue = &iValue; // pointer to value
*pValue = 4;
int& rValue = &iValue; // reference to value
rValue = 5;
Here you van see that when using a pointer (pValue) you need the to dereference it
using the '*' operator;
When using the reference (rValue) you can use it like you would have used iValue;
Now this brings the following benefit, look at the following code:
When using FunctionA the Point object will be copied onto the stack and
in the function you only use this copy. [pass by value]
When using FunctionB only the address is placed on the stack and inside the function
you can access the original object. So when changing the object inside the function is will
be changed outside the function (its the same object) [pass by address]
When using FunctionC alsoo only the address is placed on the stack and inside we are using the original object. So when changing the object inside the function is will
be changed outside the function. [pass by reference]
When passing large objects (classes with many members, or large ones) the pass by value is not so good (slow, stack space consuming). So either pass by address or pass by reference are preferred.
The reason why is? When windows was created using GDI things were written in good old C!
Unlike C++, C didnt use pass references, so you had to use pass by address.
Also since pass by Value such as :
CClientDC dc(this);<br />
CPen penBlue = new CPen();<br />
dc.SelectObject(penBlue) // pass by value, makes a copy - uses up a lot of memory (BAD)<br />
//instead use<br />
dc.SelectObject(&penBlue) // pass by address - fast and effecient, using original object (GOOD)<br />
also you could use<br />
CPen& rPenBlue = &penBlue;<br />
dc.SelectObject(rPenBlue) // not sure if this is right but pass by reference<br />
I think I understand some of it now, but theres still some things that elude me.
An example is
CClient* pDC(this);<br />
CPen penRed = new CPen()<br />
penRed.Create(PS_SOLID,1,RGB(255,0,0); // Create a solid red pen<br />
CPen penOld = dc->SelectObject(&penRed); // Select the red pen and store the old pen in // penOld, but why use the address of it?<br />
dc.DrawText(300,400,penRed,"Hello World"); // Print Hello World<br />
dc.SelectObject(penOld) //Select the old object using the pointer<br />
I still am a bit confused like the previous snippet
CRect rc;<br />
Thanks in advance again
Last Visit: 31-Dec-99 18:00 Last Update: 25-Sep-23 6:33