|
yes, me too..
I have to map enum values to a string, and back. The string is a custom string (but a "complete" solution using the name of the enum constant would be ok, too)
anybody having nicely wrapped-up solution for it?
I need two-way lookup, case insensitive...
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
There are not elegant solutions for two-way lookup using STL map. How big does the contain get? If it is relatively small, one solution is to simply use two maps.
Kuphryn
|
|
|
|
|
I'm trying to figure out what I'd need.
The lookup is ok with a single map - searching for the value linearly is fast enough. For the case-insensitive string comparison I'd use the map lookup of course
I wonder about the other stuff - keeping "enum miantenance" as low as possible.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
http://www.codeproject.com/vcpp/stl/bimap.asp[^]
Don't know whether or not it's case insensitive or not, but as it's based on STL you should be able to override the maps ordering functor (i.e. write your own less<string>)
[edit] After having read the whole article I spotted this:
bimap<
typename from_type, typename to_type,
typename from_compare=std::less<from_type>,
typename to_compare=std::less<to_type>,
typename allocator_type=std::allocator<direct_pair<const from_type,const to_type> > >
It's what you want.
[/edit]
--
Im hayu samim et hamo'ach shelcha betoch tsipor, hi hayta matchila la'uf achora!
|
|
|
|
|
Question: Can a Device Context be created by hand for a imaginary device?
Reason: I am creating an application that will be outputting (drawing) to an image device that does not have a physical Device (like a printer). I would like to create this DC so that when I do calls like: LPtoDP or DPtoLP or even doing a line MoveTo( DC, point) and a line LineTo( DC, point) that I don't have to calculate the difference.
In a 1200 dpi printer, and you want to draw a 1" x 1" rectangle you create the rectange (based upon your mapping mode, in this case we will use LOENGLISH) Rect( 100, 100, 200, 200 ) -> 1x1 rectangle starting at 1 inch from the top and left. So in a 1200 dpi this converts to 1200, 1200, 2400, 2400 in the actual drawing. I would like to be able to create a dc that does not connect to a physical device with a dpi say 350x350.
How can this be done? AND, can it be done?
Thanks
Larry
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
I believe what you want is a metafile DC. If you are using MFC have a look at CMetaFileDC . I have never used it myself, so I may be totally off base here.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
I have one telephone connection. I am using that connection for net. Now if some one ring me, It would get a busy beep. Is it possible that I make a utitlity that record the msg automatically without disconecting me from the net...
thx
|
|
|
|
|
Short answer is no.
Long answer is look for a "Internet Call Waiting" Modem-on-Hold™ (MOH)service from your telephone company. V.92 provides this sort of functionality http://www.v92.com/
|
|
|
|
|
I have one telephone connection. I am using that connection for net. Now if some one ring me, It would get a busy beep. Is it possible that I make a utitlity that record the msg automatically without disconecting me from the net...
thx
|
|
|
|
|
No, because the busy signal that the caller hears comes from the phone company, not your house. In other words, when they are calling you, the signal does not even reach your house. It is detected much further upstream that your phone is off the hook and thus tells the caller so with a busy signal.
|
|
|
|
|
Hi,
Can any one give me idea, how to develop a search engine like google. I want to build a one like this.
From where search engine get the matched string?
Is there any table where Keywords are stored?
From how I would know about URL.
I m new in programming. So plz answer in detail.
thx.
|
|
|
|
|
You're new to programming and you want to jump into the deep end of the pool and undertake such an ambitious project. Amazing. Some of my first programming projects, small as they were, allowed me to build a solid foundation first, and then add to it a bit more each time.
It's been a while but some of them I remember are:
-- Fahrenheit to celcius convertor
-- Monte Carlo anaylsis
-- Degrees to radians convertor
-- Calculate wind chill and heat indices
-- Quadratic equations
-- Complex numbers (used Ada and its flavor of classes for this)
-- Department store markup (wholesale * markup = sale price)
-- Number-guessing game
-- Split a file into two pieces, and then merge it back together
-- Various stdin/stdout type programs (e.g., pipe the output of a number file through a program to compute the average)
-- Writing to and reading from a data file
-- Various sorting and searching algorithms
-- RPN calculator (prerequisite of stacks, lists, and queues)
There are dozens more but I can't recall them right now. I think you get my point, however.
|
|
|
|
|
I'm try to create a new ListBox ... but I have a problem ..
I call myObj.Creat(...) function to creat the ListBoxExtended also with option "LBS_OWNERDRAWVARIABLE". But when I try to add a new item to list box, the MeasureItem function has not called .. but only DrawItem
can anyone help me ???
|
|
|
|
|
Hi,
look at this example taken from the MSDN:
// CMyListBox is my owner-drawn list box derived from CListBox. This
// example measures an item and sets the height of the item to twice the
// vertical extent of its text. The list box control was created with the
// following code:
// pmyListBox->Create(
// WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|
// LBS_SORT|LBS_MULTIPLESEL,
// myRect, pParentWnd, 1);
//
void CMyListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
ASSERT(lpMeasureItemStruct->CtlType == ODT_LISTBOX);
LPCTSTR lpszText = (LPCTSTR) lpMeasureItemStruct->itemData;
ASSERT(lpszText != NULL);
CSize sz;
CDC* pDC = GetDC();
sz = pDC->GetTextExtent(lpszText);
ReleaseDC(pDC);
lpMeasureItemStruct->itemHeight = 2*sz.cy;
}
this example should help you....
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
thnx .. but .. no ...
the problem is still here ... and exactly is that .. that the process doesn't enter in the function .. so the problem is not what I write inside it .. but why the MeasureItem has not called ??????
|
|
|
|
|
Is myObj of type CListBox ? What is "ListBoxExtended?" Have you declared MeasureItem() as virtual in the listbox's declaration? What does the rest of the call to Create() look like?
|
|
|
|
|
ok .. I'll try to explane better ...
I have 2 Classes ...
class MCIconListBoxDesc : public CListBox // new ListBox class
class MCIconListBoxDescItem : public CObject // items for the list box
in MCIconListBoxDesc.h I have these function
virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/);
virtual void MeasureItem(LPMEASUREITEMSTRUCT /*lpMeasureItemStruct*/);
then .. in the oninitdialog function of the project i write these lines to create new component
//m_lb is a MCIconListBoxDesc object
CRect lbRC(10,10,300,400);
m_lb.Create(WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_OWNERDRAWVARIABLE, lbRC , this , IDC_MCLB);
then in MCIconListBoxDesc.h i write a function called
void AddNewMessage(MCIconListBoxDescItem *p_item);
//definition
void MCIconListBoxDesc::AddNewMessage(MCIconListBoxDescItem *p_item)
{
m_obArray.Add(p_item); // nothing important for my problem
this->AddString(p_item->GetDateTime());
this->SetTopIndex(this->GetCount()-1);
}
then ... when I try to execute and debug application, I put a breack point at the begin of the MeasureItem function but this not stop the process .. and it goes directly at DrawItem function.
how can I do ?
I tryed also to set MeasureItem as WM_MEASUREITEM
please someone help me
|
|
|
|
|
Remarks
By default, this method does nothing. Override this method and fill in the MEASUREITEMSTRUCT structure to inform Windows of the list-box dimensions. If the list box is created with the LBS_OWNERDRAWVARIABLE style, the framework calls this method for each item in the list box. Otherwise, this method is called only once.
|
|
|
|
|
IYes .. I've just red Visual Studio Guide ... and as u can see in the create Method I've wrote LBS_OWNERDRAWVARIABLE .... but the framework NEVER calls MeasureItem
|
|
|
|
|
Hi there!
And here is my question How to get the ID of a HTREEITEM?
I inserted Items with - e.g. - InsertItem( TVIF_TEXT, strPaket, 0, 0, 0, 0, iID, hParent, TVI_SORT );
Then i used GetSelectedItem() and GetItem() to get the placed ID (iID) ... but i alway get 0 as result of lParam of the TVITEM structure
|
|
|
|
|
GetItemData() is a much better function for what you want.
That being said, how are you using GetItem()? Are you setting the TVITEM data members properly before you call GetItem()? You have to set hItem to the item handle you got from GetSelectedItem() and mask to TVIF_PARAM.
HTREEITEM item = GetSelectedItem();
TVITEM tv = {0};
tv.mask = TVIF_PARAM;
tv.hItem = item;
if (GetItem(&tv))
UINT iID = tv.lParam;
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
I found my error
I forgot to add the parameter TVIF_PARAM in the InsertItem method
|
|
|
|
|
hi!
i'm working on my first mfc-app having the following problem.
i got some arrays of classes as members of the main dialog. this works fine, only if i now add any other member (like an vector<int>) to one of the classes (which i do not use yet, they are only created and nothing is done with them yet), the programm either doesn't even start anymore, or exits with access-violation. or it works untill iquit the programm and then it throws the access violation. the debugger only brings some stuff from the (i think) main dialog constructer or destructor (depends), which i don't know what to read from.
so i guess there is some problem with the memory allocation of the main dialog because of the (not too big) members i attach. but i don't know how to solve it.
thanx for help.
alexis
|
|
|
|
|
How about some relevant code snippets?
|
|
|
|
|
that's how the class looks:
class CRawData
{
public:
Vector m_vEnergy;
Vector m_vIntensity;
Vector m_vFilter;
Vector m_vPower;
int m_iType;
vector<int> m_vIndex;
vector<int> m_vFilterAtIndex;
Vector m_vFactorAtIndex;
CRawData();
virtual ~CRawData();
void resize(int size);
void CopyFromRawData(CRawData &rawData);
bool GetFilterPoints();
bool CalcFilter();
bool FilterSteps();
};
a vector of this class is member in my main dialog. with m_vIndex, m_vFactorAtIndex and m_vFilterAtIndex i get the problem, removing them from the class solves the problem
(Vector is a typedef vector<double>).
like this:
class CRHContourDlg : public CDialog
{
// Construction
public:
vector<CString> m_sDataFile;
vector<CRawData> m_rRawData;
vector<CRawData> m_dData;
CRHContourDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CRHContourDlg)
enum { IDD = IDD_RHCONTOUR_DIALOG };
CButton m_wndFilterCheckBox;
CButton m_wndPLType;
CEdit m_sFilterExt;
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRHContourDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CRHContourDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnDestroy();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnQuit();
afx_msg void OnLoadDataFiles();
afx_msg void OnPlType1();
afx_msg void OnPlType2();
afx_msg void OnFilterSteps();
afx_msg void OnSaveFilterCheck();
afx_msg void OnChangeFilterExtension();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CGraphDlg m_dlgGraph;
};
if i now remove m_dData it works fine, like you see it it gives a access violation in the very beginning (not even showing the dialog). as i wrote already nothing is done with m_dData yet.
by the way: of course no complier errors ...
alexis
|
|
|
|