|
Nitron wrote:
I was thinkin' B coz if I set p = NULL first, delete will try to delete a *p from NULL, but the *p @ &p will still be there...
Right.
With the assignment of a new value to your pointer, you are throwing the old value away. And as this value was your only means to access (and access includes delete), you now have a memory leak.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi folks,
I have the following problem. Window B must be child w/ respect to Window A. Window A and Window B are on different threads (by the way, A is running on the main process thread). Is it possible to make window B be child of window A in such a sitiuation? if not, how to simulate the correct behaviour, for example being notified of the messages window A receive, and so behave accordingly?
Thanx a lot. You always brighten me
Andrea
|
|
|
|
|
Hello people,
I am a novice at MFC and I am stumped by a problem. What I have on the screen are few items and I have the ability to select multiple ones. The multiple items are shown by a tracking rectangle border. This mechanism is handled in OnLButtonDown() and LButtonUp() and OnMouseMove() event. My problem is when i just left click anywhere on the screen I want the selected items to be deselected ( this functionality works) However I have to make a call to UpdateWindow() and that causes the entire screen to be redrawn giving me screen flicker . Is there anyway I can only redraw part of the client area ? Sorry for thsi wordy email. I would really appreciate any help.
Thanks
newbee78
|
|
|
|
|
You should specify an update region prior to calling UpdateWindow so that only the part of the window that needs to be redraw is repainted. See the InvalidateRect member function. For more granualar control, you can also look at RedrawWindow, as it allows you combine these calls into one single call.
onwards and upwards...
|
|
|
|
|
Hello There,
Thank you very much. I am on my way
newbee78
|
|
|
|
|
Hi,
I intend to create a hidden ActiveX Control(it is a windowless control) on a UIThread. I tried to create the control using CWnd::CreateControl in the UIThread initInstance but got stuck in filling the parameters.
Finally the question is can an active X control object run & exist without having a dailog on a UIThread.If so how then? (some sample src codes)
Also i intend to use the message loop of the UIThread to get event notification on the control (A latter step)
|
|
|
|
|
DimpleSurana wrote:
CWnd::CreateControl in the UIThread initInstance but got stuck in filling the parameters.
It depends on how the control implements Create(), and/or if the control is derived from CWnd.
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
well the control extends CWnd
|
|
|
|
|
Then this should work:
m_Ctrl.Create( WS_CHILD|WS_VISIBLE, CRect(0,0,100,100), this, ID_SOMEID );
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
{Remember i am trying to create this control from a UIThread so a container for holding the control is missing, i am tryin to get the round about way if it exists so}
Okie i was successful in getting my code compiled with the following statement
BOOL CUIStatusThread::InitInstance()
{
// TODO: perform and per-thread initialization here
AFX_MANAGE_STATE(AfxGetStaticModuleState());
myctrl.Create("My window", WS_CHILD|WS_VISIBLE, CRect(0,0,100,100), AfxGetMainWnd(), ID_SOMEID );
return TRUE;
}
but it gives a Debug Assertion Failure in occcont.cpp Line 62 on this statement -
ASSERT(pParentWnd != NULL);
I guess this should make the picture clear for u.
dimple
|
|
|
|
|
I am using SetCursor and LoadCursor to change the cursor.
m_hCursor = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_BUTTON));
m_hOldCursor = SetCursor(m_hCursor);
I have this code in OnInitDialog() in a dialog based application but the cursor doesn't seem to change to my cursor. I have also Tried using IDC_HAND which is a windows cursor incase my cursor was bad. I also change AfxGetInstanceHandle to NULL in LoadCursor with no luck. In the debuger, m_hCursor and m_hOldCursor have valid address but my cursor doesn't seem to change....
Anyone?
Thanks
Ralph
|
|
|
|
|
You need to handle the message WM_SETCURSOR via the virtual handler OnSetCursor. The function is called repeatedly, so it should be optimized. In this handler and in the OnMouseMove handler is where you would call SetCursor.
onwards and upwards...
|
|
|
|
|
Try this code:
<br />
BOOL CSystemTray::SetIcon(UINT nIDBigIcon, UINT nIDSmallIcon, CStatic *pWndList, int nListNumber)<br />
{<br />
ASSERT (!nListNumber || (NULL != pWndList));<br />
m_hIcon = AfxGetApp()->LoadIcon(nIDBigIcon);<br />
m_hSmallIcon = AfxGetApp()->LoadIcon(nIDSmallIcon);<br />
ASSERT ((NULL != m_hIcon) && (INVALID_HANDLE_VALUE != m_hIcon));<br />
ASSERT ((NULL != m_hSmallIcon) && (INVALID_HANDLE_VALUE != m_hSmallIcon));<br />
if ((NULL == m_hIcon) || <br />
(INVALID_HANDLE_VALUE == m_hIcon) ||<br />
(NULL == m_hSmallIcon) || <br />
(INVALID_HANDLE_VALUE == m_hSmallIcon))<br />
return FALSE;<br />
<br />
CDialog::SetIcon (m_hIcon, TRUE);<br />
CDialog::SetIcon (m_hSmallIcon, FALSE);<br />
if (nListNumber && <br />
(NULL == pWndList))<br />
return FALSE;<br />
int i;<br />
CStatic *pPt = pWndList;<br />
for (i = 0; i < nListNumber; i++, pPt++)<br />
{<br />
pPt->SetIcon (m_hIcon);<br />
}<br />
return TRUE;<br />
}<br />
where:
<br />
protected:<br />
HANDLE m_hCompletion;<br />
HICON m_hSmallIcon;<br />
HICON m_hIcon;<br />
<br />
This works great. I did not test it with icons loaded from different modules neither with string-named resources (only index-named ones).
Hope this help.
Regards,
Andrea
|
|
|
|
|
Hi !
I'm using CVS in the developpement of my application.
I'd like that in that About Box of my app, the actual version of my application is automatically updated by CVS.
I first did defined this in a file of my application : #define REV $Revision:$
and CVS automatically updates the value of this define.
The problem is that the number I get is actually the revision of one single file, where I'd like to have the version of my global application.
I haven't used cvs tags yet, and I don't know if this would be a solution : can I retrieve in my code the tag of a set of files ?
Would you have another solution to my problem ?
Thanks !
Jerome
|
|
|
|
|
<br />
void CDialog::OnMouseMove(UINT nFlags, CPoint point) <br />
{<br />
CPoint point;<br />
CWnd *wd;<br />
<br />
GetCursorPos(&point);<br />
if( (wd = WindowFromPoint(point)) )<br />
{<br />
SetCursor(LoadCursor(NULL, (wd->GetDlgCtrlID() == IDCANCEL) ? <br />
IDC_ARROW : IDC_WAIT));<br />
}<br />
}<br />
hello. i've got a lengthy op and therefore an hourglass as mouse cursor. it should stay that way while not pointing to the cancel button. i wrote the code above to accomplish this.
problem: my dlg has also got a toolbar and 2 radio buttons that seem to override all this; the mouse icon is always an arrow when i point on them.
can somebody help, please?
Я люблю русский язикь!
|
|
|
|
|
You should override OnSetCursor associated to the message WM_SETCURSOR so you get notified when the cursor is to be changed...
|
|
|
|
|
In my program I need to control the connecting time,which means that when I use connect() to connect another machine,I can set how many seconds before the function return.
if u can give me some hint,u will give me a big faver!
|
|
|
|
|
Before calling connect, add a call to set the socket up as non-blocking:
ULONG ulParam = 1;
ioctlsocket(m_hSocket, FIONBIO, &ulParam);
Then call connect as normal.
After calling connect, you can do a select (writing) with whatever timeout you want to see if the socket has connected - if the socket can be written to it is
connected.
Regards,
Simon
|
|
|
|
|
I have a project which is an MFC resource-dll .
It contains several .rc files.
Two of these .rc files contain Icons.
All the icons have different IDs and are decalred in this fashion :
IDI_MY_ICON ICON "icons\\test.ico"
This generates the error:
fatal error CVT1100: duplicate resource. type:ICON, name:1, language:0x0409
If I allow only one of the files to contain icons, everything works.
My question is what can I do about this ? Is there a way to tell one of the resource files to start from a different internal-index or something like that ? because it seems like the icons are simply colliding internaly... (remember they have different IDs)
thanks
|
|
|
|
|
The name IDI_MY_ICON is just a macro. The resource file will include a header file somewhere that has the numeric values of the definitions. Your header files have clashing declarations - two resources numbered 1.
Once you get beyond a single .rc file, I recommend managing your identifiers yourself, rather than relying on Visual C++ / Visual Studio. It isn't designed to manage multiple resource files.
|
|
|
|
|
the IDI_MY_ICON was just an example.
If I declare an icon with ID let's say 124 in one file, and another icon with ID 312 in the other file, I get this error.
That's why I said it seems like some internal collision...
The mere fact that two .rc files contained Icons (non-clashing icons) generated this error.
And what does the 'Name' field mean in the error-string ? all my IDs are much higher than 1...
|
|
|
|
|
I'm trying to create common contros by coding and not through the resource editor. The problem is that the controls simply do not appear. They're being created with the CPropertyPage being their parent and then calling ShowWindow(SW_SHOW) on them.
Anyone to help ?
Thanks.
|
|
|
|
|
Did you ::InitCommonControlsEx ?
Also try to fire up a spy++ to see if those controls were created and if there were, what is there position.
Edward
|
|
|
|
|
Is it possible to align the property sheets in a Dialog in a vertical fashion rather than the usual horizontal way on the top of the dialog???
|
|
|
|
|
Hi,
I am creating an app, very much similar to a mini database. Now my problem is, I need to execute a QUERY on tables. There will be only a max of 4 fields in the queries WHERE clause. Then I need to filter the data based on the WHERE condition supplied. Any suggestions on what sort of data structure should I go for ? ( I can even load the whole thing into memory at startup if reqd.,since memory is not a constraint. )
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|