|
Windows XP comes with DAO 3.6 preinstalled, all others have nothing. You might try SQLite at http://www.hwaci.com/sw/sqlite/
I've used it before and it works quite well. No nice fancy wrappers tho (I have one internally,but it's certainly not ready for primetime).
Small footprint (200k roughly), most SQL syntax, single file, transactions.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
Anyone ever have a problem where, for some reason, they can no longer add any subitems to a listview?
I have been banging my head on this for two days now. The code is as follows:
for (int i = 1; i <= num_vbpc_channels; i++)<br />
{<br />
lvi.mask = LVIF_IMAGE | LVIF_TEXT;<br />
strItem.Format(_T("Item %i"), i);<br />
<br />
lvi.iItem = i;<br />
lvi.iSubItem = 0;<br />
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);<br />
lvi.iImage = i%8;
m_cListCtrl.InsertItem(&lvi);<br />
<br />
strSubItem1.Format(_T("%s"), "Past");<br />
strSubItem2.Format(_T("%s"), "Past");<br />
<br />
lvi.iSubItem =1;<br />
lvi.pszText = (LPTSTR)(LPCTSTR)(strSubItem1);<br />
m_cListCtrl.SetItem(&lvi);<br />
<br />
lvi.iSubItem =2;<br />
lvi.pszText = (LPTSTR)(LPCTSTR)(strSubItem2);<br />
m_cListCtrl.SetItem(&lvi);<br />
<br />
}
Most of you will probably notice this code as it is (for the most part) a copy/paste from one of the MFC examples here. It works for a few runs then simply stops adding sub items. The first column of items always gets added...
UGH!
|
|
|
|
|
The code seems OK. Matt Weagle, in his article Using the List Control[^] shows some code that is almost identical to yours. You might try downloading the demo project he provides to try to determine the differences that are causing the strange behavior in your app.
PS: Your loop begins at 1 instead of 0. I don't think this is where the error stems from, but definitely you should begin at zero.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Items start with number 0, not 1, I'm surprised you're seeing any subitems at all actually.
Zero-fill the LVITEM struct before setting its members. Not doing so can make the code fail in release mode. (Even though the mask field is there to indicate which members to use, the control still validates some of the other fields.)
Also, your (LPTSTR)(LPCTSTR) cast of a CString is incorrect code (although it happens to work here because the string isn't modified).
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Michael Dunn wrote:
Also, your (LPTSTR)(LPCTSTR) cast of a CString is incorrect code (although it happens to work here because the string isn't modified).
This is code directly out of an article from here. The article is cited in the message above.
Why is it incorrect? Actually, why is it used in the first place. You have to forgive me, I am an emerging C++/MFC programmer....
|
|
|
|
|
It is incorrect because CString provides a read-only array. If you want to modify the string, you have to use CString methods or overloaded operators like += .
Casting to LPCTSTR is fine, because CString provides that conversion itself, and still results in a read-only pointer. Casting that to a LPTSTR (which is not const ) gives you a read-write pointer to a read-only buffer. It compiles (because casts override type checking), and it even runs in your case, but that doesn't make the code correct.
The correct way to get a non-const pointer to the CString 's buffer is GetBuffer() .
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Also, your (LPTSTR)(LPCTSTR) cast of a CString is incorrect code
It is perfect code, no cast is superfluous. pszText is a non-const LPTSTR (because some CListCtrl methods use it as an out parameter).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
It is perfect code, no cast is superfluous.
Agreed. LVITEM::pszText is non-const, because structure is used in both LVM_SETITEM/LVM_GETITEM contexts.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Joaquín M López Muñoz wrote:
It is perfect code
Hardly. See my post above.
Encouraging code like that will get people into trouble, because if they use that unsafe cast everywhere, it will eventually break, and they'll wonder "why isn't this working? I copied it from XYZ and it worked fine there".
I prefer to show people the correct code (CString::GetBuffer() ) so they learn the proper way to do things, instead of unsafe hacks that just happen to work in some situations.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Ok, so I'm quasi-newb, and my apps are starting to outgrow dialog-based interfaces. With multi top-level windows and window position sizing algorithms, I meagerly try to simulate a doc/view interface only because I finally know how to pass data between dialogs and have no clue how to use doc/view. Most of my stuff is graphing apps using National Instruments Active-X controls (starting to outgrow these too). I feel I end up doing things the very hard way, but I learn more each time through. Also, the data files I deal with are usually giant csv files. I have implemented a serializing vector routine and the fun zlib compression library, so my file IO is coming along... Anyway, can anyone point me to a simple doc/view sample where someone who is used to setting things up on OnInitDialog() and laying things out on a dialog (using ETSManager to resize them) can learn how the doc/view works. I guess my questions are so basic, they may seem trivial to most, but I don't even know how to get a control in a view and display it if it's not a dialog app Sad, I know. But at least I keep trying...
Thanks all!
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Start with a wizard generated SDI app: when selecting the type of view, choose it to be derived from CFormView . Now you've got a CFormView which plays a very similar role to a CDialog , try migrating the code of some of your dialogs to it (ETSManager and all). The data is supposed to live in a CDocument -derived class: this is initially almost empty, but you can easily plug your data management routines there. Views are not meant to hold nor serialize any piece of data, but instead they shouuld be accesing it thru the document class (see CView::GetDocument ). By the time you've managed to get this working you'll be familiar enough with the framework to attempt MDI, which allows you to have multiple docs and views open at a time.
Apart from this, try searching any tutorial on SDI/MDI on the net.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanx.
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
This is driving me nuts! In one of my windows, I want to bitblt a particular bitmap when the mouse is over a given region. Everything works except the window repainting itself. The region in question is at one edge of the window. If I mouse over that region, then go off the window and click the window under it and then bring my window back to the front, the bitmap has been blitted. In a nutshell, I do the following:
- in response to WM_MOUSEMOVE I test to see if in the region; if so, I set a flag. I invalidate that rectangle and do an UpdateWindow to force a WM_PAINT
- in response to WM_PAINT, I call my function that does the blitting of the bmp.
Is there something special about drawing on a window that I'm missing?!
things could always be worse...
|
|
|
|
|
...I invalidate that rectangle and do an UpdateWindow to force a WM_PAINT
Try (for debugging purposes) invalidating the whole window instead. If this causes the window to be correctly repainted, then probably you're miscalculating the dimensions of the rectangle.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
also, you might want to track WM_MOUSELEAVE message.
here is a snip to how to get this message:
TRACKMOUSEEVENT structEventTrack;
structEventTrack.cbSize = sizeof(structEventTrack);
structEventTrack.dwFlags = TME_LEAVE;
structEventTrack.hwndTrack = this->GetSafeHwnd();
structEventTrack.dwHoverTime = HOVER_DEFAULT;
_TrackMouseEvent(&structEventTrack);
and in your handler to WM_MOUSELEAVE message, you might want to clear your flags which was set during mousemove.
|
|
|
|
|
Hi,
I need to get hold of some algorithm for doing lexicographic text
matching - the way it works for wildcard. Could anybody give me
some URL or article extract?
e.g.:
abc* matches abcdef but does not match abdef.
?XYZ matches MXYZ but does not match MNXYZ.
With best regards,
Sayan
Email:sayanmukherjee@indiatimes.com
|
|
|
|
|
|
A dilemma:
I want a "done" button to be disabled until the user adds omething to the CEdit. Fine. I trapped the EN_CHANGE, and the button comes alive as soon as the user enters anything. Problem is, I dont ever want this field to be empty, and if after typing a letter in, the user goes back and deletes it, my "done" button is still enabled. It should only be enabled when theres something in the CEdit.
How do I do this?
======================================================================================
My other tactic was to test when the "done' was pressed like this(below) but it freezes my program and doesnt give me a chance to enter something into the CEdit:
void CDlgMineName::OnButtonDone()
{
CString UserEntry;
m_editMineName.GetWindowText(UserEntry);
while (UserEntry =="")
{
m_editMineName.SetFocus();
m_editMineName.GetWindowText(UserEntry);<code>why cant I enter anything here? </code>
}
It freezes and I have to kill it from task manager. Is it obvious why ?
Thanks,
ns
|
|
|
|
|
ns wrote:
I trapped the EN_CHANGE,
So EN_CHANGE isn't sent when user deletes text from edit control?
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
It probably is, but heres what I do in the function:
void CDlgMineName::OnChangeEditminename()
{
m_buttonminename.EnableWindow(TRUE);
}
If the change was of a "negative type" i.e. nothings left in the CEdit, I want to EnableWindow(FALSE), so should I do a GetWindowText in this event and see if its empty?
void CDlgMineName::OnChangeEditminename()
{
CString abc;
m_myEdit.GetWindowText(abc);
if(abc=="")
{
m_buttonminename.EnableWindow(FALSE);
}
else
{
m_buttonminename.EnableWindow(TRUE);
}
}
What do you think about this? Too contrived?
Thanks,
ns
|
|
|
|
|
One line does it all:
m_button.EnableWindow(m_edit.GetWindowTextLength() > 0);
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
For the EN_CHANGE you would just write
CString name ;
m_editMineName.GetWindowText(name) ;
GetDlgItem(IDC_BUTTON_DONE)->EnableWindow(name.GetLength() > 0) ;
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Thanks! I was going about doing that but I really like your succintness and style!
Thanks,
ns
|
|
|
|
|
Hi,
Please find below a possible way to do it using MFC. It is in your lines
of thought and EN_CHANGE does it.
When the application starts the button will be disabled. As you type in the
edit box or delete text EN_CHANGE fires. Keep on measuring the length of the
string.
Code follows:
Class declaration:
<br />
class CEditControlDlg : public CDialog<br />
{<br />
public:<br />
CEdit *m_pEdit; <br />
CButton *m_pButton; <br />
<br />
CEditControlDlg(CWnd* pParent = NULL);
}<br />
Function definition - InitDialog():
<br />
BOOL CEditControlDlg::OnInitDialog()<br />
{<br />
CDialog::OnInitDialog();<br />
<br />
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
<br />
m_pEdit = (CEdit *)GetDlgItem(EF_TEXT); <br />
m_pButton = (CButton *)GetDlgItem(PB_DONE); <br />
<br />
m_pButton->EnableWindow(FALSE);
return TRUE;
}<br />
Function definition - EN_CHANGE handler function:
<br />
void CEditControlDlg::OnChangeText() <br />
{<br />
<br />
CString strText;<br />
<br />
m_pEdit->GetWindowText(strText);<br />
<br />
if (!strText.GetLength())<br />
{<br />
m_pButton->EnableWindow(FALSE);<br />
}<br />
else<br />
{<br />
m_pButton->EnableWindow();<br />
}<br />
}<br />
With best regards,
Sayan
Email:sayanmukherjee@indiatimes.com
|
|
|
|
|
I'm automating Excel from C++ using OLE.
Sometimes, I give a command to excel. Excel handles the command and finishes it, BUT excel doesn't return back to my c++ app.
In my c++ app, I'm calling pDispatch->Invoke(...), the method or property is indeed invoked, you can see the result in the excel sheet. But the invoke method never returns and hangs...
My guess is that it's wndmessage-related.
btw. my app is in fact an mfc-dll. InitInstance() is called but Run() is never called.
Anybody knows why? Do I have to override the excel messagepump?
PLEASE, any suggestions are fine...
tnx
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|