|
Hi,
Based on the value 'SELECTED' I am trying to do some statements.
The following code doesnt work for the two values of 'SELECTED'.
typedef enum{
APPLE =0,
ORANGE =1
}FRUITS;
#define SELECTED APPLE
#if SELECTED == 1
AfxMessageBox("orange");
#else
AfxMessageBox("apple");
#endif
Kindly help.
Priya Sundar
modified on Tuesday, May 19, 2009 6:04 AM
|
|
|
|
|
#if is a pre-processor directive processed by the preprocessor and enum and AfxMessageBox are handled by the compiler. You cannot mix them this way. What is it that you're trying to do here?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
«_Superman_» wrote: You cannot mix them this way.
Tell me one thing if I replace enum with #define and instead of AfxMessageBox, I define varA, then it compiles.
#define APPLE 0
#define ORANGE 1
#define SELECTED APPLE
#if SELECTED == 1
int varA = 100;
#else
int varA = 101;
#endif
Replacing enum with #define is fine but isn't the definition of varA also handled by compiler only?
I mean why int varA = 101; is ok and AfxMessageBox not?
|
|
|
|
|
I bet you have put that globally. I mean outside of all functions.
You cannot call a function globally unless you are assigning to a variable.
Try this.
#if SELECTED == 1
int varA = AfxMessageBox(L"Selected");
#else
int varA = AfxMessageBox(L"Not Selected");
#endif
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Yeah! u r correct!
But why so?
I mean why is it ok if I assign it to an int and not otherwise?
|
|
|
|
|
It isn't about a function call actually.
It is about initializing a global variable even if it means calling a function to do it.
So we can use that trick to execute a function even before the entry point of a program.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
#define APPLE 0
#define ORANGE 1
int varA = 0;
#define APPLE_DEFINED
#ifdef APPLE_DEFINED
varA = 100;
#else if ORANGE_DEFINED
varA = 101;
#else if PAPAYA_DEFINED
varA = 102;
#endif //APPLE_DEFINED
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Priya_Sundar wrote: #define SELECTED APPLE
As you've heard you can't do that. In the above line APPLE is not defined so SELECTED remains undefined so you always get
Priya_Sundar wrote: AfxMessageBox("apple");
You can only use
#define APPLE 0
#define ORANGE 1
|
|
|
|
|
Thanks All...
by defining it as 0 and 1 its resolved.
Priya Sundar
|
|
|
|
|
sir/madam,
i want to set a image as background for toolbar base on dialog,but i do not know to do it,i know do it on view/Frame,because i do not know execute OnPaint function in CToolbar base on dialog,i need your help,thanks.
|
|
|
|
|
Bitmap ToolBar[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
thank your answer,,i had got the demo,but it implement on view/fram,,i need implement it base dialog,,i search much,,but did not get needing answer.
|
|
|
|
|
Is your problem for displaying the toolbar on the dialog or you have already done it and then problem is with the display of the image on the toolbar?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
i have already shown toolbar on dialog,now my problem is how to display background image for the toolbar.
|
|
|
|
|
hi
i want to develop a MFC application to control my system volume and mike(line-in) settings.Kindly help me.
thanx in advance.
|
|
|
|
|
You can use dierctsound API for this. Its avialable in MSDN.
|
|
|
|
|
Does this help?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
ya this works well thanx for the code.
but can u please help me how to change volume of (line - in) mike.
|
|
|
|
|
Sorry to trouble you guys, but I think I'm missing something in my understanding of the List Control boxes.
I'm creating a CListCtrl box with 3 columns. The first 2 are text and the third will show bitmaps. My code goes like this:
void PopulateList ()
{
LVCOLUMN lvColumn1,lvColumn2,lvColumn3;
COLORREF rgbMask = RGB(0,0,0);
CImageList ThumbList;
ThumbList.Create(MAXWIDTH, MAXHEIGHT, ILC_COLOR, 1, 1);
lvColumn1.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvColumn1.fmt = Alignment;
lvColumn1.cx = 120;
lvColumn1.pszText = ColumnHeading[0];
nCol = m_MainList.InsertColumn(0, &lvColumn1);
int NextIndex = nCol;
while (!EOF)
{
.
.
LVITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = NextIndex;
lvItem.iSubItem = 0;
lvItem.pszText = OutputTitle;
NextIndex = m_MainList.InsertItem(&lvItem);
.
}
ListView_SortItemsEx( m_MainList.m_hWnd, CompareProc, (LPARAM)&m_MainList );
lvColumn2.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvColumn2.fmt = Alignment;
lvColumn2.cx = 120;
lvColumn2.pszText = ColumnHeading[1];
nCol = m_MainList.InsertColumn(1, &lvColumn2);
int NumOfEntries = m_MainList.GetItemCount();
for(int i=0; i>NumOfEntries; i++)
{
.
.
.
m_MainList.SetItemText(i,1, <Data>);
}
lvColumn3.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvColumn3.fmt = Alignment;
lvColumn3.cx = 240;
lvColumn3.pszText = ColumnHeading[2];
nCol = m_MainList.InsertColumn(2, &lvColumn3);
NextIndex = nCol;
BYTE PreviewInfo[MAXHEIGHT][MAXWIDTH][3]={0};
int ImageIndex = 0;
for(int i=0; i<NumOfEntries; i++)
{
BOOL ValidPicture = ReadDataFromDataFile(.....);
if(ValidPicture)
{
HBITMAP Picture = <Data Read>
CBitmap *ThumbNail = new CBitmap;
ThumbNail->Attach(Picture );
ImageIndex = ThumbList.Add(ThumbNail,rgbMask);
m_MainList.SetImageList(&ThumbList, LVSIL_SMALL);
LVITEM lvItem;
lvItem.mask = LVIF_IMAGE;
lvItem.iItem = i;
lvItem.iSubItem = 0;
lvItem.iImage = ImageIndex;
NextIndex = m_MainList.InsertItem(&lvItem);
delete ThumbNail;
}
else NextIndex++;
}
}
m_MainList is the handle to the CListCtrl on the dialog
If I don't code in the Column 3 code, I get my first 2 columns ok. Once I do put in the Column 3 code, Column 1 data all disappears and Column 3 also has no data.
I believe the problem is in my declaration of the CImageList and how I am putting it into the Column, but I don't know what is wrong and also why Column 1 is being affected.
Can someone point me in the right direction here?
|
|
|
|
|
JJeffrey wrote: lvItem.iSubItem = 0;
Try changing that line to
lvItem.iSubItem = nCol; ?
|
|
|
|
|
No change in output. Column 1 data disappears. Column 3 remains empty
|
|
|
|
|
I'm an f-ing idiot at times....
First problem - you've made your image-list local to the PopulateList function - it needs to be alive as long as the list control is alive (makes sense?), so declare it at class scope with the list control variable.
Second problem - the image index refers to the optional icon that can be to the left of the text in the first column. You can only put text in the rest of the columns - that's the bit I should have remembered
To get images in an arbitrary column, you need to use custom-draw. Or a ready-written list control sub-class, like the ones here on CodeProject[^]. This one[^], for example, allows images in any column.
|
|
|
|
|
Thanks again.
I'm still trying to work out the solution after shifting everything to the CQuickList class. Took me a while to figure out how to use the class even with the webpage.
Thanks.
|
|
|
|
|
Hello,
I need to create a transparent overlay window, that goes above another window. The other window is from another vendor. And when the user drags that window mine needs to follow.
WS-CHILD seems like a nice idea but it cannot be combined with WS-EX-LAYERED, which I really need (for transparency). But I still can set a parent without using WS-CHILD.
Parenting does give my winproc notifications (WM-WINDOWPOSCHANGING), but only after dragging is complete, on mouse-up. To give a nice feeling i need to get those notifications (or for example WM-MOVE) continuosly while dragging.
I guess my problem is similar to docking, but the fine docking solution seen fx at CodeProjet uses WS-CHILD. ( http://www.codeproject.com/KB/toolbars/dockwnd.aspx )
I know I could use ::SetWindowsHook(). But that is my final resort. And I guess I could use polling but that is not what I am looking for. I am hoping I have missed something trivial and that somebody can point me in a good direction.
Thanx
........................
Life is too shor
|
|
|
|