|
toxcct wrote:
for the portability of bool, i agree. We should prefer BOOL instead...
no, BOOL is MS-specific, bool is ANSI C++. Also, you should always compare via similar types, so a correct form of the original (according to my profiler) would be:
bool bAllowUnvalidateTextResult = (siteFlags.GetNbrValue(ALLOW_UNVALIDATE_TEXTRESULT) == 1) ? true : false;
that is, if GetNbrValue returns an int .
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Nitron wrote:
bool is ANSI C++
yes. int too. and to prevent any change between architectures, the types ares redefined to be similar on every systems. that's called portability
Nitron wrote:
Also, you should always compare via similar types
but the implicit casts also exist ! i only said that my code line was working. i never said it was the best !
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
i only said that my code line was working. i never said it was the best !
I know, and I do it too, what I was saying was that my Parasoft C++ Test profiler says it's bad practice, but hey, what do profilers know
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
What if GetNbrValue() returns 2? Do all non-zero values indicate true?
How about:
bool bAllowUnvalidateTextResult = (siteFlags.GetNbrValue(ALLOW_UNVALIDATE_TEXTRESULT) == 0) ? false : true;
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
atenshun to detale!
i like, i like!
Bikram Singh
|
|
|
|
|
bool a = b != 0;
That works just fine and IMHO is much clearer.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I've a got a problem using a MsFlexGrid control in a CDialogBar window.
I've developed a new class derived from CDialogBar in order to manage the DialogBar window.
My project is a MDI and the instance of my class (derived from CDialogBar) belongs to CMainFrame class.
My problem is the following:
- the MsFlexGrid control doesn't receive any user interface event (scroll up, scroll down, onbutton, and so on....). When the main window is shown, and the DialogBar is shown within it, the user can't manage the MsFlexGrid control: in example, clicking on scroll bar buttons doesn't have any effect.
I think I need to write some code in CMainFrame class in order to let it map all MsFlexGrid control windows messages, but I don't know how to do it !
I'm able to do it for other controls like buttons, listboxes and so on... but I think is not the same for MsFlexGrid. For that kind of controls I use the following code in CMainFrame:
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)<br />
ON_BN_CLICKED(IDC_BTN_MY_BUTTON, CDlgbarMyDialogBar::OnBtnMyButton)<br />
END_MESSAGE_MAP()
But I'm almost sure it is not the same for the MSFlexgrid. By the way I don't need to write any code to let a listbox work in a CDialogBar...
so, can someone help me ?
Thank you very much !
|
|
|
|
|
If it is possible I would like to know how could I get the (x,y) coordinate just by flying over the chart by the mouse, that is how do I translate the screen coords catched by the mouse to the x,y coords of the MSChart.
Thanks in advance to any reply
|
|
|
|
|
Hi, I am a newbie using MFC. Most program scripts were copied from either books and examples.
I encounter a difficulty when I wanna to scroll view and print preview.
//======================
void CSLReaderView::OnDraw(CDC* pDC)
{
CSLReaderDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//change the mapping mode
pDC->SetMapMode(MM_LOENGLISH);
//plot a rectanglar first, height 400 pixels, not shown in the script
// display data here
pDC->TextOut(100, -500, "RECORDING REPORT");
for (i=0; i<n; i++)
="" {
="" sprintf(s,="" "%3d",="" pdoc-="">m_SLDA[i].LAi);
pDC->TextOut(100, -540-i*20, s);
}
CSize docSize(100, 400+(N+10)*20); //doc size
CRect rect; //cal page size
GetClientRect(&rect);
CSize pageSize(rect.right, rect.bottom);
CSize lineSize(0, 20); //line size
SetScrollSizes(MM_LOENGLISH, docSize, pageSize, lineSize);
}
void CSLReaderView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
}
void CSLReaderView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
CSLReaderDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int pageHeight = pDC->GetDeviceCaps(VERTRES); //page height (dots)
int logPixelsY = pDC->GetDeviceCaps(LOGPIXELSY); //dots/inch for pt int plotHeight = (int) (4.0*logPixelsY); //rectan->pixels for pt
int lineHeight = (int) (0.2*logPixelsY); //line hight->pixels for pt int numPages = (pDoc->m_SLDA.GetSize()*lineHeight + plotHeight) / pageHeight + 1;
pInfo ->SetMaxPage(numPages);
}
void CSLReaderView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
if (pDC->IsPrinting())
{
int pageHeight = pDC->GetDeviceCaps(VERTRES);
int OriginY = pageHeight * (pInfo->m_nCurPage-1);
pDC->SetViewportOrg(0, -OriginY);
}
//CScrollView::OnPrepareDC(pDC, pInfo); //CONFLICT 1: if so, print preview can not show the 2nd page
//CView::OnPrepareDC(pDC, pInfo); //CONFLICT 2: if so, view can not scroll
}
The conflict comes from the last two commands OnPrepareDC(), if use only the first, print preview can not show the 2nd page, i.e. all pages are the same. if use only the second, the view can not be scrolled properly in view.
Thanks for your time. The code is long but I have no other ways to describe it better.
Regards,
Nelson
|
|
|
|
|
Hai all,
I am uncleared with the logic used in the OnprepareDC() and OnDraw() functions in the the view class of the DRAWCLI sample application from microsoft msdn samples.
Can any one explain me.
Thanks,
Arun Chakaravarthy
|
|
|
|
|
HI,
I have captured the Video using VC++ and DirectShow.
in ASF fromat.
Now i want to send it on on Network ... (LAN) to other Computer ..
if i will be able to send it ,,, then i will recieve it.
what r the ways (solutions) ...
any idea , help , sample etc.
waitng
thanx
|
|
|
|
|
Client/Server sockets?
and
I believe Microsoft® Windows Media is Content that can be distributed by network streaming, downloading, and progressive downloading. (from MSDN)
|
|
|
|
|
I know it is by Sockets and client\server or peer to peer approach is used
I already saved it in ASF (WMV) format.
i think to ways on to transfer a grabed picture quickly.
or to send a viceo buffer.
But who can Buffer a video ( live preview ) or if
i send a grabbed pictures so in wt format should these be. i think a fast processing is required to grabb and send a picture quickly that shows a continous motion .
any idea or details
plz
waiting
thanx
|
|
|
|
|
Visit avphone home:
http://www.banasoft.net/AVPhone.htm
|
|
|
|
|
Hai all,
I am created Dialog Bar with buttons in Win CE, I loaded Bitmap on the button,It is placed on the left side of the client area, whenever the movement of the mouse occurs on the particualar coordinates the dialog bar displays with its buttons. It displays so nicely, but the mouse move event donot recognize the buttons on the dialog bar. It recongizes only the client area not the dialog bar.
DARWIN PAUL RAJ
|
|
|
|
|
Hi,
Im new to windows programming.
While working out with scroll bars I'm facing a problem.
In my createWindow API I havegiven the WS_VSCROLL flag, and so the window that appears has the vertical scroll bar.
Now to this main window I have added some 100 child windows one below the other (window class = STATIC) starting a Y-axis positions 0, 100, 200, 300 and so on. Now since I cannot see all the 100 child windows.
But if I click on the vertical scroll bar also, it does not work.
The scroll bar does not work at all.
Shud I do something else in addition. i.e. should i handle the vscroll click messages. If so what shud be the code in my message handler for the same ? I guess I do not have to do some complex mathematics ?
Many Thanx
Kiran
|
|
|
|
|
From my experience with working HWNDs and scroll bars, I have always had do something like the following :
- when a new child is created, I had to calculate the rectangle of my TOTAL window (even the part I can't see)
- using the part I can see, I can calculate the range of the scroll bar and set it :
SetScrollRange(hWnd,SB_VERT,0,300,TRUE);\
- then I would handle the scrolling, and call MoveWindow.
I believe that is what I do at home when I'm handling
some of the drawing and scrolling myself.
|
|
|
|
|
Hello,
I want to call a particular topic (HTML page) of help (HTML Help) in a tabbed dialog box in MFC. I am not aware of MFC much. Where is the "Help" button in the dialog? Its not there in the dialogs created in Dialog resources. Has anyone implemented such thing? I want the ID of the help button so that i can call the corresponding help of the dialog box. If possible please provide me with example program.
thanks
Regards
Priya
|
|
|
|
|
Are you using a CTabCtrl or a CPropertySheet ? I've not ever used the former, and the latter gives you a working Help button.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
-Is there something that I can do in C and not in C++?
|
|
|
|
|
I believe there are several things you can do in C++ but not in C.
The most obvious being the use of Classes (inheritence,virtual functions etc).
|
|
|
|
|
What did you mean by that? Application programs? Or the syntax?
If you were talking about the syntax, YES! There are some part of ISO C 9899 syntax not supported by ISO C++ 14882.
Maxwell Chen
|
|
|
|
|
Theoretically: No
practical there is a huge difference.
In C you can work closer with memory and stuff (eg. String handling...) Is more difficult. C++ is a bit safer .
Quote:
"C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."
- Bjarne Stroustrup
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
Read four sections of this C++ FAQ beginning here.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
No. Both are Turning Complete, and therefore anything you can write in one you can in the other.
However there are strong reasons to use one over the other anyway. There are many things that are easier to write in C than C++, and vise versa. (C++ is easier for large teams/projects, C is easier for direct to hardware performance counts programs. Even this is a gross over generalization and you can find exceptions)
Turing complete is named for Alan Turing who proved sometime ago (1930s? +-20 years) that any program that you can impliment in one language can be implimented in any other. The simplest turning complete language supports one command: subtract branch on zero. (don't ask me who to prove that)
|
|
|
|