|
simply put, you window is not valid when it was closed.
Yes, these kind of problems are quite common in VC++ w.r.t apps running in Debug and not working on Release.
Since you need to take care while multithreading in MFC, I do notknow how the you have created the window, which thread own/created the window. Does that thread has its own message loop, etc ,etc.
-prakash
|
|
|
|
|
Thank you for the reply
here is part of the dialog window:
BOOL CSurchrgApp::InitInstance()
{
.....
CSurchrgDlg dlg;
m_pMainWnd = &dlg;
dlg.DoModal();
}
when I set breakpoint at dlg.DoModal(); I would get the &dlg, dlg and m_pMainWnd with {CSurchrgDlghWnd=0x0000000}, but this seems like the standard coding, not sure why it's getting all the 00000000......
|
|
|
|
|
See http://www.codeproject.com/debug/survivereleasever.asp
|
|
|
|
|
Using Shared Memory with a large structure, but when I start a new project using the current one as a basis, the names referenced in the structure are the old names and not the new names.
If I type in the new names then All OK, but if I select old name from list error (as would expect). But how to arrange for the display of new structure items in the list.
Is this an IDE bug or does the registry need a tidy up (and how).
<br />
struct TSharedMemory{<br />
....<br />
....<br />
};<br />
<br />
g_hMap = ::CreateFileMapping((HANDLE) 0xFFFFFFFF,<br />
NULL,<br />
PAGE_READWRITE,<br />
0,<br />
sizeof(TSharedMemory),<br />
"TP_SharedMem"<br />
);<br />
if(g_hMap == NULL)<br />
{<br />
int s = GetLastError();<br />
g_szFormatting.Format ("Shared Memory Not Obtained (Signals); Error = %d", s); <br />
AfxMessageBox(g_szFormatting);<br />
}<br />
else<br />
{<br />
g_hMap = (TSharedMemory*)::MapViewOfFile(g_hMap,FILE_MAP_WRITE,0,0,sizeof(TSharedMemory));<br />
<br />
memset(g_pMem, 0, sizeof(TSharedMemory));<br />
}<br />
<br />
memcpy(&g_pMem->tips.buffer, &BCbuffer.data , sizeof(BCbuffer.data));
i.e. when you type &g_pMem-> its the old names that are shown.
|
|
|
|
|
hi,
i want to know if it's possible to trigger an event in ms-word from mi MFC project, i.e. trigger a button click event without clicking that button with the mouse..
thanx
|
|
|
|
|
Hi,
I've put a ComboBox control into a toolbar using clickety[^], and want to trap the user pressing enter. However, this keypress seems to disappear into the aether, and I can't trap it using OnChar, OnSelendok, or any of the other message handlers I've tried, in any of the Main Frame, view or combobox classes!
Any idea where the Enter keypress goes?
|
|
|
|
|
Not sure about ComboBoxes as I've not tried to do this, but have you tried handling the CBEN_ENDEDIT message from WM_NOTIFY?
In your message map add
ON_NOTIFY_REFLECT(CBEN_ENDEDIT, OnEndEdit)
and in your class you'd add a method such as
void Class::OnEndEdit (NMHDR *pNMHDR, LRESULT *pResult)
{
...
*pResult = 0;
}
I did something akin to this when catching the end of someone editing a List Control edit thingmy.
Note that I make no guarantee's that this will do anything close to what you want.
|
|
|
|
|
As an additional note, you should cast pNMHDR to a NMCBEENDEDIT*, and it will show you the reason why you're in your function:
NMCBEENDEDIT* pCBEnd = (NMCBEENDEDIT*)pNMHDR;
if (pCBEnd->iWhy == CBENF_RETURN)
Or something like that.
I'd try coding it up to prove my theory, but I'm too busy thinking up silly things to say in the Lounge.
|
|
|
|
|
Thanks for the suggestions. I found this[^] which sorted it out in a slightly different way.
|
|
|
|
|
Hello everybody,
I have next problem :
I have a MFC Dialog based application and i am retrieving some info from a *.mdb database using CDatabase and CRecordSet classes. I am doing this without any problems.
But my question is how to add a new record in this database ?
My code looks like this :
CDatabase database;
CString sSQL;
CString sName,sSurname,sID;
CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)";
CString sFile = "c:\\db1.mdb";
CString sDsn;
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sFile);
TRY
{
database.Open(NULL,false,false,sDsn);
CRecordset recset( &database );
database.Close();
}
CATCH(CDBException, e)
{
AfxMessageBox("Database error: "+e->m_strError);
}
END_CATCH;
I guess i'm supposed to use AddNew() ,Requiry() ,Update() functions.
MSDN says : "AddNew prepares a new, empty record using the recordset's field data members. After you call AddNew, set the values you want in the recordset's field data members. " - how can i set the values ???
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 9:22 Monday 3rd October, 2005
|
|
|
|
|
Hi how ru
this is Vikas again
put this code in the Try block
CString SqlString;
// write the query and attach to the SqlString
database.ExecuteSQL(SqlString);
This is the simple way but i dont think u have
a static data , Meaning u r going to get data
from the user and then add it to the database
right for that u need to use format string that
is bit syntatic .
ok
take care
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
could you be more explicit?
can you provide sample code ?
thanks
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 10:14 Monday 3rd October, 2005
|
|
|
|
|
Try to use the query i have given u
in this code in the TRY block
SqlString.Format(_T("INSERT INTO Recordset_name(ID,Name,Surname) VALUES
(%d,%s,%s)"),i_ID,c_Name,c_surname);
database.Exectue(SqlString);
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I've added next code in TRY block
...
CString name,surname;
name="Jon";
surname="Doe";
int nID=200;
SqlString.Format("INSERT INTO Table1 (ID,Name,Surname) VALUES (%d,%s,%s)",nID,name,surname);
database.ExecuteSQL(SqlString);
...
but i get exception thrown , with message box : "Database error. Too few parameters.Expected 2"
after i modified the code like this :
SqlString = "INSERT INTO Table1 (ID,Name,Surname) VALUES ('200','jon','doe') ";
everything is ok ,do you know whats wrong with the previous code
thanks for help
[Fixed]
I found out why exception was thrown.
Instead of :
SqlString.Format(_T("INSERT INTO Recordset_name(ID,Name,Surname) VALUES<br />
(%d,%s,%s)"),i_ID,c_Name,c_surname);
I had to write :
SqlString.Format(_T("INSERT INTO Recordset_name(ID,Name,Surname) VALUES<br />
('%d','%s','%s')"),i_ID,c_Name,c_surname);
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 15:50 Monday 3rd October, 2005
|
|
|
|
|
Hi Giorgi,
I use http://www.codeproject.com/database/caaadoclass1.asp[^]
With those classes, you first need to open a transaction in CADODatabase, then call AddNew in CADORecordset, then call CommitTransaction in CADODatabase to commit the changes to the database. Your classes might be similar. You also need to make sure that you have select and editing privileges in the database!
HTH.
|
|
|
|
|
thanks
I'll take a look
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Hi
To add new Record
1. open RecordSet
2. Call AddNew()
3. Assign values to field variables (rs.m_Name = "John"; )
4. Call Update()
but in this case I think your Recordset is readonly,you most open it using ODBC or DSN.
Iman Ghasrfakhri
-- modified at 11:41 Monday 3rd October, 2005
|
|
|
|
|
Ghasrfakhri wrote:
(rs.m_Name = "John";)
thanks but,
I don't know how to declare m_Name variable and bind it to "Name" Field
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 11:52 Monday 3rd October, 2005
|
|
|
|
|
if you use VS 6.0 use Class Wizard to create a new class With bass CRecordset class, the CW ask you about your DB select DAO & select your DB. it do that for you.
& if you use VS .Net Choose Create new Class & Select ODBC classes, it is the same.
Iman Ghasrfakhri
|
|
|
|
|
Hi,
I have two tiff images and I am loading them into CBitmap using GDI Bitmap class. I am using one of the image to paint the background of a dialog and its working fine. Now I would like to use the second image to draw on top of the first. The second image has some transaparent areas and those areas should be replaced with the image in the back( first image).
I tried several examples in Codeproject, But I am getting the transaparent area filled with blue.
Can someone pl. guide me on doing this.
Thanks
San
"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."
|
|
|
|
|
Try to create a new view which is
overlapped on the dialogbox.
The first image should be in CStatic
control.
The second image should be manually
drawn on the view by editing the
function OnDraw(CDC* pDC).
This might work but dont know about
the windows message realted to it.
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
|
Maybe you can use TransparentBlt() in NT. This is an easiest way to paint with a transparent color.
|
|
|
|
|
Hi there,
I have an addin to ms Word written in visual c++ implementing the IDTExtensibility2 interface.
I sink events properly and launch my functions...
My question is..how can I call those functions from a different c++ project?(that should be possible)
need I to register them as word native functions, can I use messages to call them?...
thanks and happy codding
AB.
|
|
|
|
|
Hello Friends,
I'm developing an application in which there are few dialog boxes and i decided to make them colourful using bitmaps,So i used the OnEraseBkGnd function to load the bitmaps .but there was an mismatch between the dialog size and bitmap size so i decided to capture the size of the dialog and the bitmap,after which i repainted the dialog calling the BitBlt function many number of times.
Is there anyother way to load the bitmaps so that i dont have to call the BitBlt function more than once.I've attached the piece of code what i'm using now.it'd be great if someone could help me in this...
BOOL dialog::OnEraseBkgnd(CDC* pDC)
{
CBitmap bmp;
CBitmap *ptrBmpOld;
CDC dcMemory;
BITMAP bm;
CRect rect;
int i, j;
int nHor, nVer;
bmp.LoadBitmap(IDB_BITMAP1);
bmp.GetBitmap(&bm);
GetClientRect(rect);
nHor=rect.Width()/bm.bmWidth+1;
nVer=rect.Height()/bm.bmHeight+1;
dcMemory.CreateCompatibleDC(pDC);
ptrBmpOld=dcMemory.SelectObject(&bmp);
for(i=0; i<nhor; i++)
{
for(j="0;" j<nver;="" j++)
{
pdc-="">BitBlt
(
i*bm.bmWidth,
j*bm.bmHeight,
bm.bmWidth,
bm.bmHeight,
&dcMemory,
0,
0,
SRCCOPY
);
}
}
dcMemory.SelectObject(ptrBmpOld);
return TRUE;
}
Rajeev
-- modified at 8:05 Monday 3rd October, 2005
|
|
|
|
|