|
Take a look at RegEnumKeyEx.
Also check help for 'Registry Functions'
regards,
Louis.
|
|
|
|
|
I am writeing a windows program that runs a file i/o function that takes a while to run, and I can't figure out how to make it update the programs window while it is running the funtion. How do I get it to run the window's window procedure in the middle of the function? (I think that is what I have to do..)
This is probably a really easy thing to fix, but I can't figure it out.
BTW this is a dialog based program (a dialog made in the resource editor) if that makes any difference..
Any help would be greatly appreciated.
Thank You.
|
|
|
|
|
Hi!
Put the following function into your dialog class
and call it in the file i/o loop. This will ensure
that the window messages are correctly disptached.
void CYourDialog::PumpMessages()
{
static MSG msg;
if( GetSafeHwnd() != NULL )
{
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( !IsDialogMessage( &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
}
}
HTH
Holger Persch
|
|
|
|
|
|
Hi.
It looks like I am missing NAFXCWD.LIB and gets some linker errors.
Can anyone be so kind to mail me this file or tell me where to find it.
Email: patrik.andersson@kvarnstrands.se
Regards
Patrik
|
|
|
|
|
That's one of the MFC statically-linked libs. Just grab it off your VC CD and copy it to <vc6 install="" dir="">VC98\MFC\LIB.
|
|
|
|
|
I'm having a weird problem where my CListCtrl doesn't show all the items that I load in it. I'm using
a function to load the control initially using LVITEM with InsertItem() followed by SetItem() for all
subitems, and this part works.
However, as the program is running I have to update the listctrl so I call ResetContent() to clear the rows
and then call the initialize function mentioned above to reload everything. The problem is that when I
do this, only the first item shows up in every row. Usually the subitems are blank in most of the rows.
Some rows do show up correctly, but this is only on a few rows. When I say correctly I mean all
subitems are shown with the main row item. Can someone help me with this?
Thanks in advance,
--Trey
|
|
|
|
|
Hi Trey,
Very weird! Maybe there's a bug in the initializing function... Can you provide some code?
Paolo.
|
|
|
|
|
Ok, I have a database objectthat has two vectors of CStrings. I update the database and then call LoadListData(). Like I said before this is weird!
Here is the code to initialize the data:
void CMyDlg::LoadListData(CDatabase* database)
{
// Delete the current contents
m_cListCtrl.DeleteAllItems();
// Use the LV_ITEM structure to insert the items
LVITEM lvi;
lvi.mask = LVIF_TEXT;
CString strItem;
int numberOfAddresses = database->GetAddressCount();
for (int i = 0; i < numberOfAddresses; i++)
{
//*
CAddress* a = database->GetAddress(i);
// Filter if necessary
if(m_bFilterOn && a->m_csCategory != m_csFilterCategory)
continue;
// Insert the first item - First Name
lvi.iItem = i;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR)(a->m_csFName);
m_cListCtrl.InsertItem(&lvi);
// Set subitem 1 - Last Name
lvi.iSubItem = 1;
lvi.pszText = (LPTSTR)(LPCTSTR)(a->m_csLName);
m_cListCtrl.SetItem(&lvi);
// Set subitem 2 - Company
lvi.iSubItem = 2;
lvi.pszText = (LPTSTR)(LPCTSTR)(a->m_csCompany);
m_cListCtrl.SetItem(&lvi);
// Set subitem 3 - Address 1
lvi.iSubItem = 3;
lvi.pszText = (LPTSTR)(LPCTSTR)(a->m_csAddress1);
m_cListCtrl.SetItem(&lvi);
// Set subitem 4 - Address 2
lvi.iSubItem = 4;
lvi.pszText = (LPTSTR)(LPCTSTR)(a->m_csAddress2);
m_cListCtrl.SetItem(&lvi);
// Set subitem 5 - City
lvi.iSubItem = 5;
lvi.pszText = (LPTSTR)(LPCTSTR)(a->m_csCity);
m_cListCtrl.SetItem(&lvi);
// Set subitem 6 - State
lvi.iSubItem = 6;
lvi.pszText = (LPTSTR)(LPCTSTR)(a->m_csState);
m_cListCtrl.SetItem(&lvi);
// Set subitem 7 - Zipcode
lvi.iSubItem = 7;
lvi.pszText = (LPTSTR)(LPCTSTR)(a->m_csZipcode);
}
}
|
|
|
|
|
Well, what I can see is: it lacks the last SetItem.
For ther rest it seems OK.
Try doing ASSERTs on the return value of each SetItem and go with the Debug version.
Also, you may try to add:
ZeroMemory(&lvi, sizeof(LVITEM));
just after the definition.
I found that sometimes this could help... or does nothing
Paolo.
|
|
|
|
|
I'm still having problems. Can anyone help me please? I'm only using the report mode and I have added the columns correctly. Like I originally stated, I'm able to load the listctrl successfully once.
|
|
|
|
|
I've created an Edit control as a Child Window of Internet Explorer Band. This gets loaded at the bottom for every instance of IE.
But whenever I type in the Edit control, a few keys are not functioning ( Like Back Space etc.,).
Is there a solution for this?
Looking for your guidance
Siva
|
|
|
|
|
I've created an Edit control as a Child Window of Internet Explorer Band. This gets loaded at the bottom for every instance of IE.
But whenever I type in the Edit control, a few keys are not functioning ( Like Back Space etc.,).
Is there a solution for this?
Looking for your guidance
Siva
|
|
|
|
|
Did you implement IInputObject?
|
|
|
|
|
Hi,
I'm a student working on a project and I'm stuck and running out of time! God please help me!!!!
I'm trying to convert data in text files(i.e data in notepad) into Microsoft Access Tables.
In order to convert data in text files into access tables, the user is to provide 2 text files(usually done with notepad), the first one has a .name extension(i.e. example.name), and the other has a .data extension(i.e. example.data). the file with the .name extension will contain names, or attributes which will be used as the field names for the access table. (i.e cusotmer name, product#, etc). the .data extension file will contain the actual data for each field. (i.e john smith, JK-1345).
My program is suppose to take the data from the 2 text files, read the data from the .name files, create a new table and plug in the names to create the fields for the table. Then the other text file with the .data extension will be read and the values will be plugged into the newly created table.
My problem is that I don't know how to create a new table from VC++6. The books that I've been referring to only shows examples that deal with tables that have already been created. How exactly do I create new tables and insert the values from the two files with VC++6???
If you can provide with some sample codes that would be greatly appreciated. Thank you very much and PLEASE HELP ME!
I'm trying to do this using a option from a menu created in a single document.
Sincerely,
Steve
One more thing, do I have to create an empty project in Microsoft Access first in order for me to create new tables?
|
|
|
|
|
You need to look at CDaoDatabase::Create and CDaoTableDef::Create in the MFC DAO documentation.
Create (database) will create the .mdb. You shoudn't need to create the access .mdb file first.
CDaoTableDef can Open or Create tables in a database.
Then CDaoTableDef::CreateField ...
Just a point here tho - if you have a text file of columns of data, its really easy to open access, open/create a db, and use the File | Import dialog to bring the data in. Optionaly, you can specify that the first line in the file contains the field names.
You'll get finer control over the TableDef and Field attributes doing it programmatically, but its going to be a bit more work.
|
|
|
|
|
Hello, codegurus around the world.
How about using SQL statement directly.
After you create table.txt and insert.txt, you can use
ADO or the other class to execute SQL.
But, in this case, you must create the blank database file of Access first.
(table.txt)
CREATE TABLE Customer (
Name char (15),
Product_name char (15),
primary key(Name));
(insert.txt)
INSERT INTO Customer VALUES ('Masaaki', 'Nike');
.......
You can restore these info to strSQL(CString) by reading the file by each line or buffer, and execute these SQL by class member function like open().
Good luck.
-Masaaki Onishi-
|
|
|
|
|
Just wanted to say thanks!
|
|
|
|
|
Is anybody have the ready made source code for edit control that immitates winword text box. please help.
thank you.
|
|
|
|
|
Although I can't offer you the full functionality of the Winword text box, we do offer a free masked edit control class that would handle much of the number formatting I think.
The class is available as part of our free download collection, and the link is provided from our main page.
Enjoy.
David
Dundas
http://www.dundas.com
|
|
|
|
|
Hi,
I'm trying to render graphics and text into RTF and then send it WordPad (i.e. the rich edit control).
I found an article that tells you how to do render graphics into RTF
(http://codeguru.earthweb.com/mfc/comments/3811.shtml).
The technique is to convert the graphic into a metafile and then embed the metafile using the RTF keywords "\pict \emfblip \bin"
and the GetEnhMetaFileBits function, however wordpad doesn't recognise these keywords.
If you save a RTF file from wordpad, the graphics are saved using the "\pict\wmetafile8" keyword,
followed by the binary data of the graphic.
However, I can't find any documentation any where that tells in what format the binary data is in.
If any one can help me with this it would be greatly appreciated.
|
|
|
|
|
Okay after a lot of trial and error I figured out how to do it.
The trick is to use the old windows metafile format and use the wmetafile8 keyword.
Here is a piece of code that gets the metafile of an OLE control and renders it into RTF,
then puts it onto the clipboard:
if ( OpenClipboard() )
{
EmptyClipboard();
UINT format = ::RegisterClipboardFormat(CF_RTF);
CSharedFile sf(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT);
CString str = _T("{\\rtf1 ");
sf.Write(str, str.GetLength());
CMetaFileDC * pDC = new CMetaFileDC();
pDC->Create(NULL);
pDC->SetAttribDC(m_vectorDlg.GetOCXPtr().GetDC()->m_hAttribDC);
CRect rect;
m_vectorDlg.GetOCXPtr().GetWindowRect(rect);
m_vectorDlg.GetOCXPtr().ScreenToClient(rect);
m_vectorDlg.GetOCXPtr().PrintCtrl((LPUNKNOWN)pDC, rect.left, rect.top, rect.right, rect.bottom);
POINT pt;
pt.x = rect.Width();
pt.y = rect.Height();
pDC->SaveDC();
pDC->SetMapMode(MM_HIMETRIC);
pDC->DPtoLP(&pt, 1);
pDC->RestoreDC(-1);
int xExt = abs(pt.x);
int yExt = abs(pt.y);
int YTwips = (int)((double)rect.Height()/(double)pDC->GetDeviceCaps(LOGPIXELSY) * 1440);
int XTwips = (int)((double)rect.Width()/(double)pDC->GetDeviceCaps(LOGPIXELSX) * 1440);
HMETAFILE hMF = pDC->Close();
int nSize = GetMetaFileBitsEx(hMF, 0, NULL);
LPBYTE lpbBuffer = new BYTE[nSize];
nSize = GetMetaFileBitsEx(hMF, nSize, (LPVOID)lpbBuffer);
str.Format("{\\pict\\wmetafile8\\picw%d\\pich%d\\picwgoal%d\\pichgoal%d ",
xExt, yExt, XTwips, YTwips);
CString strBytes;
LPBYTE pBuffer = lpbBuffer;
for (int n = 0; n < nSize; n++)
{
strBytes.Format("%02x", (*pBuffer));
str += strBytes;
pBuffer++;
}
sf.Write(str, str.GetLength());
str = _T("}}");
sf.Write(str, str.GetLength());
HGLOBAL hMem = sf.Detach();
if (hMem)
{
SetClipboardData(format, hMem);
}
CloseClipboard();
delete lpbBuffer;
delete pDC;
}
I think the code that works out the scaling isn't exactly correct, but you get the general idea.
The reason that this was so difficult is that the so-called "open" RTF format is so badly documented.
|
|
|
|
|
How can I stop a dialog from being closed when ESC is pressed?
/XTSea
|
|
|
|
|
Hi,
fast solution!
1) catch OnCancel and don't call the parent.
void CMyDlg::OnCancel()
{
//CDialog::OnCancel()
}
2) Change ID of cancel button ID_MY_CANCEL and create a function.
void CMyDlg::OnMyCancel()
{
CDialog::OnCancel();
}
3) Test it.
Bye
Peter
|
|
|
|
|
Proces the WM_CLOSE message and only allow the window to close when it should.
|
|
|
|