|
Try LZ4 (http://code.google.com/p/lz4/[^]). It's great, though I don't know how much it would help you since that's a very short string and not very compressible as is.
|
|
|
|
|
If your input characters are all 0-127 ASCII, you could store 9 characters in 8 bytes. It only amounts to about a 12.5% savings (which does not meet your requirement), but it's easy enough to code up.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I was just wondering, but have you made any progress with this?
|
|
|
|
|
yes. the answer is base64. (since all characters are alphanumeric, they can be encoded in 6 bits instead of 8)
btw, thank you all for your answers.
|
|
|
|
|
I want to check the checkboxes in a CLIstCtrl object, on a CDialog based application:
void CTestListCtrlDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if(0 <= pNMListView->iItem)
m_List.SetCheck(pNMListView->iItem, TRUE);
*pResult = 0;
}
when I made a click on a list item, the checkbox of the clicked item will check, but when I try to check the checkbox from check box itself (made a click inside of checkbox), it does not check it ... why ? It will be checked only from a double-click ... what I'm doing wrong ?
|
|
|
|
|
The list control handles clicks on the check box itself. Whenever a click on the box occurs, the check is toggled. When now clicking on a check box, your handler will set the check and the default handler which is called afterwards will toggle the check so that it is removed. This can be verified when you click on a marked check box: The check marker disappears.
The solution would be to do nothing in your handler when clicking on the box. To determine the width of the check box, use ImageList_GetIconSize passing the image list returned by GetImageList(LVSIL_STATE) . The check box itself is drawn with some spacing so that it may be necessary to add some pixels to the width.
|
|
|
|
|
But I am already do nothing in checking box handler ... or not ? The only method that I had used is:
void CTestListCtrlDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if(0 <= pNMListView->iItem)
m_List.SetCheck(pNMListView->iItem, TRUE);
*pResult = 0;
}
is the only thing that I treat it ...
|
|
|
|
|
You are setting the check marker when clicking on a row. That is more than nothing.
I will try to explain in more detail what happens:
When you click on a row right of a check box:
Your handler is called and sets the check.
When you click on a check box:
Your handler is called and sets the check and then the internal check box click handler is called and toggles the check.
What I mean with do nothing: When clicking on the check box, your handler should not set the check.
|
|
|
|
|
Yes, I understand now ... I'm getting harder ... thanks ! You are trying to say that when I click on checkbox (inside of checkbox) I will do nothing ... remain the question, how can I know if I had click inside of checkbox, or not ? I will start digging ....
|
|
|
|
|
The passed struct to the click handler is of type NMITEMACTIVATE . This struct contains the ptAction member indicating where the click occurs. You must check if the x position is right of the check box (see my first answer on how to determine the width of the check box). As far as I remember, the width is 13 pixels by default. But there is also some spacing between the left border and the check box. To make it more complicat, you must also check if the list is scrolled horizontically.
|
|
|
|
|
I think that I had solved :
void CTestListCtrlDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
const CPoint pt = pNMListView->ptAction;
const BOOL bCurrentCheckState = m_List.GetCheck(pNMListView->iItem);
if(0 <= pNMListView->iItem && 15 < pt.x)
m_List.SetCheck(pNMListView->iItem, ! bCurrentCheckState);
*pResult = 0;
}
I don't know if is OK, but seems to work ...
|
|
|
|
|
Fine that it is solved. So it seems I was right with 13 pixels width when there are 2 pixels spacing.
|
|
|
|
|
I want to kindly thank you ! Best wishes ! Bye !
|
|
|
|
|
Look the fragment of this code. I wanted to ask, why Draw text to static bitmap does not work.
m_bmpModulation.CreateBitmap(xOrder, yOrder, 1, 24, (void *)lpBits);
if (!::IsWindow(m_staModulation.m_hWnd))
m_staModulation.Create(_T("A bitmap static control (A)"), SS_CENTERIMAGE | SS_BITMAP | WS_VISIBLE, CRect(20, 20, 20 + xOrder, 20 + yOrder), this);
m_staModulation.SetBitmap((HBITMAP)m_bmpModulation);
delete [] lpBits;
CDC *pDC = m_staModulation.GetDC();
if (pDC)
{
int nIldMin, nIldMax;
swscanf(set.m_strModulationIldMin, L"%d", &nIldMin);
swscanf(set.m_strModulationIldMax, L"%d", &nIldMax);
int x, y;
x = 218 - (int)(nIldMin * (float)197 / (float)295);
y = 0;
pDC -> DrawText(L"Min", 3, CRect(y, x, y + 20, x + 13), 0);
x = 218 - (int)(nIldMax * (float)197 / (float)295);
pDC -> DrawText(L"Max", 3, CRect(y, x - 13, y + 21, x), 0);
float fFrequency;
CString str;
str = set.m_strModulationFrequency;
str.Replace(L",", L".");
swscanf(str, L"%f", &fFrequency);
str.Format(L"%.02f", (double)1 / fFrequency);
pDC -> DrawText(str, str.GetLength(), CRect(290, 224, 330, 236), 0);
}
else
AfxMessageBox(L"No Device Context.");
}
I think, problem is, that drawed text is under the bitmap. Any suggestion how to fix it?
modified 15-May-13 3:37am.
|
|
|
|
|
|
Hi, everyone.
I am finding solution which can use to read Excel format into MFC. I have questions in next 2cases. Answer me please.
case 1. Without MS Office package.
Although Excel isn't installed in my computer, I must read excel file into my MFC program. How can I parse this format without execl's COM interface?
case 2. importing Excel version is different.
I installed Excel 2007 into my computer, but I must read Excel 2010 file into my MFC program. If MS Office were installed in my computer, we can use to read Excel format into MFC using Excel's open COM interface. But, when supporting version is different from my version, how can I solve this problem?
|
|
|
|
|
|
You can use ODBC driver for Excel and read a data from Excel sheet by database functions (CRecordSet etc.).
|
|
|
|
|
There are four ways to read and write Excel files:
- Using Excel Automation (COM / OLE Dispatch) with the Excel type library. This requires an installed Excel on the machine running your application and the Excel type library on the development machine.
- Using ODBC. Open Database Connectivity is an operating system independent standard for database management. With Excel ODBC drivers, it can be used to read and write Excel files. Because it is a database interface, it handles sheets from an Excel file like tables in a database file. The required Excel ODBC driver is installed by the Windows Setup.
- Using ADO (OLE DB). ActiveX Data Objects is like ODBC a database interface, handling sheets from an Excel file like tables in a database file. It is more up-to-date than ODBC. This requires the ADO DLL wich is installed by Windows Setup. ADO may be also used to connect to Excel files using the ODBC drivers using a different connect string.
- Using a library that provides reading and writing Excel files.
Examples are:
- BasicExcel [^],
- ExcelFormat Library [^] (based on BasicExcel),
- LibXL (commercial) [^].
When deciding to use ODBC or ADO, ADO is preferred because the ODBC drivers has some limitations due to bugs and ADO supports accessing fields by value while ODBC only supports text strings.
To use ODBC and ADO with Excel 2007 files (XLSX), the 'Microsoft Access Database Engine 2010 Redistributable' package must be installed.
To exchange data with Excel, two additional methods using text formats can be used:
- Creating Text, CSV, RTF, or HTML files that can be opened by Excel and other spreadsheet programs or save data from within Excel in one of these formats.
- Providing Text, CSV, RTF, or HTML data for clipboard and OLE Drag&Drop operations.
With Excel 2007, the new OpenXML based file formats (mainly XLSX, XLSB, XLSM) has been introduced. Later versions use the same format. Older Office versions including the viewers can use the new format when installing the Microsoft Office Compatibility Pack.
|
|
|
|
|
Now say a very big thankyou to those two previous excellent answers....
==============================
Nothing to say.
|
|
|
|
|
Thank you very much. I recieved your solutions sufficiently. Have a nice day!
|
|
|
|
|
We are currently maintaining a Windows application (MFC). Which retrieves data
from an XML files.
The XML file contains large data to display the UI components which are
created dynamically in
the CScrollView window or class.
Under Windows XP platform the UI components can be created dynamically and
displayed in the
CScrollView properly. The UI components are so large. 504 components to be
exact. These contains buttons,
labels, edit box, spinners, comboboxes and others. The window or screen does
not get corrupted or
destroyed. The vertical scollbar works properly.
But under Windows 7 platform, the UI components are not displayed properly.
When it reach to a certain group no, the groups are overlapping other groups resulting to a bad display. The vertical scroller or scrollbar does not work properly. I already tried comparing the values that holds the sizes and ranges for scroll member variables but so far they have similar values. This program had already handled the above 32k range scroll range issue.
We are currently maintaining this project in a Visual Studio 2005 C++ project (IDE).
|
|
|
|
|
Hello,
What does it mean: "The vertical scroller or scrollbar does not work properly"? Does it mean you cannot use it? Is it disabled? or just screen is not refreshed properly?
If I understood the effect on Win7: "overlapping controls" maybe the problem is with graphics card? I know cases from my application, that on some poor graphics cards on Win7 with AERO turned on scrolling rows containing many editable controls caused strange screen effects. The solution was to update graphics card driver or turn the AERO off. It helped in all cases.
|
|
|
|
|
I think its not from the graphics card since it should only display texts. The vertical scroller is still good at the first few groups but when it reaches to a certain group, all the remaining groups are displayed at the same place overlapping each other. At first, we thought that it reached the maximum scroll range but the thing is, We already had a method that handles that exception and it worked fine in win xp environment but not in win 7.
|
|
|
|
|
In my case there were just texts too. The problem was not with advanced 3d graphics, but with srolling many controls containing simple texts. 8 columns and 20 rows each filled with one control, scrolled on Win7 with Aeoro turned on on some Intel grapcics chipset caused overlapping.
Could you show us this special method? What does it do, that problem is solved for Win XP? Maybe some methods are not supported by Win7. Or Win7 uses other dlls version, which are not good for your solution from WinXp.
|
|
|
|
|