|
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.
|
|
|
|
|
I need to update the cut, copy, and paste items on the edit menu before the edit menu is shown. However, I'm learning that this doesn't work in a dialog based application. I know there has to be a way to do this. Can someone help me out?
|
|
|
|
|
Well, since nobody replied to me, I figured that I would post for the sake of everyone else.
I found that to update menu items in a dialog, you need to intercept the WM_INITMENU msg. Then do your enabling and disabling.
For controls like buttons and such, you can intercept the WM_KICKIDLE msg. Then inside there you can call UpdateDialogControls(). This doesn't call the UPDATE_COMMAND_UI for the menu controls though. That's why you have to intercept WM_INITMENU.
Hope this helps.
--Trey
|
|
|
|
|
Hi,
I'm using a wang image edit ctrl in coordination with a database. I want to display simple text annotations programmatically. I used the stamp Text annotations but there is no way to set their height and width parameters.
If i use the text annotations, i'm not able to set text programmatically (there is no SetAnnotationText() fct).
all this in VC++.
How can i either set height and width of the stamp text annotations or set text programmatically with the text annotations ?
I also want to perform Drag and Drop operations but it seems that those fcts are only available in VB.
Thanks
|
|
|
|
|
Hello, I have got a MDI interface with Child windows that own Property sheets:
CChildFrmA::CChildFrmA()
{
m_PS = new CPropSheetA("",this,0,5); // overloaded to set the # of pages dinamically
}
BOOL CChildFrmA::PreCreateWindow(CREATESTRUCT& cs)
{
cs.cx = 514;
cs.cy = 436;
cs.style = WS_CHILD | WS_VISIBLE | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX | WS_OVERLAPPED;
cs.dwExStyle |= WS_EX_CONTROLPARENT;
m_PS->SetWizardMode();
m_PS->Create(this,WS_CHILD | WS_VISIBLE);
m_PS->SetActivePage(0);
return CMDIChildWnd::PreCreateWindow(cs);
}
Now I get the wanted result but ther is still a problem: in this application the mouse can't be used, and I can't set the focus to the firs control of the first property page without it, I've tried to use Setfocus when the Child Window is being activated, and when it gets the focus, but there's no result, then I've tried to use a thread to do it, and yes, the focus it's placed to the control, but it gets as it was disabled (it don't works).
Please, if someone know how to solve this or how to give me some indications of where I can find information about it, it would be fantastic.
Thank you in advance
PD: I'm very novice, if you see something that's extremely wrong I would like to know it, thanks and as always excuse my english...
|
|
|
|
|
Hi
I have a application running which got tree control in it(say Windows explorer). I get the handle of the tree control through another program (my program) and then try to get the tree control items string. But I always get null, but even though I can do other operation like delete a particular item from it. (both the program are in different process).
Cant I get the string for a third party application running in a different process? I know I can get string from the edit control, but I could not get from a tree control.
Regards
Ravi
|
|
|
|
|
I assume you have a char buffer and you're putting its address in a TVITEM struct, and passing that struct in a TVM_GETITEM message? That won't work because the process with the tree can't access the memory in your process. You're lucky the other process isn't GPFing, actually.
|
|
|
|
|
Yes, I did the same. But I could get the edit box text, how?
Also Is there a way to get the tree control item and its strings?
regards
Ravi
|
|
|
|
|
Becuase you get an edit box's text with GetWidowText(), which is designed to work between different processes.
|
|
|
|
|
Thanks Mike for your answers!
But I dont understand they gave the capability to GetWindowText but not to treecontrol! If they gave they should have given to all or just none!
Oh boy, I want to get the strings from the control!!! any help is appricated!
regards
Ravi
|
|
|
|