|
I think that you should bring in another class that handles your threads - one that holds back the return of the main.
main(...)
{
ClassThreads = new clsClassThreads();
do
{
existCondition = ClassThreads->Start();
if (existCondition)
{
ClassThreads->getResults();
//do something with thread results.
ShowMessage("Thread class done. Exiting loop and Main");
}else{
ShowMessage("Thread class not done yet. Restarting threads");
}
}while(!exitCondition)
delete ClassThreads;
return 0;
}
|
|
|
|
|
errr....
I am only using C, so could you give me some information related to it?
|
|
|
|
|
Sorry - Im was wrong - the fact that it works in foreground i missed. Ignore my posting. I thought you had a code design issue.
Well, other guy suggested the os. I would say the same. And i think it is something you'll find in Linux articles. I don't know C threads and linux in the detail you might need.
|
|
|
|
|
I'm Frustrated. in .NET a easy Control.Add(new TextBox()) will create a textbox during runtime.
Do anyone know of a way to add controls to a panel during runtime? (or form)
And also may someone point me to some litrature that *explains* the advanced methods with respect to controls and control containers in C++ VCL?
Appreciate it
|
|
|
|
|
You can use of Create or CreateWindow or you can declare a variable for example CButton m_button; m_Button.Create(...); and after create it declare events for it.
|
|
|
|
|
In addition to WhiteSky's reply...
Everything you ever wanted to know (and more) about Windows controls can be found here:
Individual Control Information[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Thanks for Info,
I got it.
The Create and CreateWindows seemed to be a bit low level programming.
I found a InsertControl(TWinControl*) on the panel that i missed. It works perfect.
I program in Borland using VCL - so the Create does not exist.
Thanks anyhow.
|
|
|
|
|
InOut.NET wrote: I program in Borland using VCL
I missed that
We were referring to Windows APIs, so yes, low level.
Cheers!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Hi,
i have done an mdi application in which all views will have bitmaps as background. I am attaching bitmaps in Onpaint() function of all views.In some view classes i am creating font every time i am calling onpaint function.
this is the code
void CMyView::OnPaint()
{
CPaintDC dc(this); // device context for painting
AttachBitmap(IDB_USERNAME, &dc, CRect(631,23,766,58));
CFont fFont;
CFont *fOldFont;
if(fFont.CreateFont(11,0,0,0, FW_BLACK ,false, false, false, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma")!=NULL)
{
fOldFont = dc.SelectObject(&fFont);
}
}
this is attachbmp function
BOOL AttachBitmap(UINT sBMPFile, CDC *pDC, CRect rect)
{
CDC memDC;
CBitmap cBitmap;
CBitmap* pOldMemBmp = NULL;
if(!cBitmap.LoadBitmap(sBMPFile))
AfxMessageBox("ting");
memDC.CreateCompatibleDC(pDC);
pOldMemBmp = memDC.SelectObject(&cBitmap);
BITMAP bmpInfo;
cBitmap.GetBitmap(&bmpInfo);
TransparentBlt(pDC->GetSafeHdc(), rect.left, rect.top, rect.Width(), rect.Height(),
memDC.GetSafeHdc(), 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight,COLORREF(RGB(0,255,0)));
if (pOldMemBmp) pDC->SelectObject(pOldMemBmp);
return TRUE;
}
these functions are used in almost all views of my mdi application.
Problem is that after running application for more than oneday.. bitmaps are getting disappeared and system is showing virtual memory of your system is low. and a warning appears as font cannot be created .. what could be the reason? any help is appreciated.
thank you
chaitu
|
|
|
|
|
This means you're leaking memory. The GDI memory you're leaking is the bitmap itself, I believe. Why do you load it every time ? Make it a member variable, so you load it only once, that just makes sense.
Either way, I'm not sure if that solves the core issue, but it might, it will sure simplify the code. But, somewhere in your app, you are leaking GDI resources, and you're running out.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi graus ,
thanks for your reply, i will try that..
|
|
|
|
|
I have created dsn at runtime but i have to enter the values like- user name, password also at runtime.
So how can i do this in vc++?
plzz help me..
thanks in advance
|
|
|
|
|
In the fourth argument to SQLConfigDataSource() , you could try the UID and PWD keywords. Those may be driver specific, however.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Dear all
I have one double number which i want to round to nearest decimal number in Visual C++.
What is the function to do this
REgards
Monhi
|
|
|
|
|
double d =whatever;
int i = (int)(d + .5);
Please note that, as pointed out by Rage it doesn't work properly with negative numbers See the fix here [^].
-- modified at 8:10 Tuesday 10th July, 2007
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
d=-5.6 => i=-5, not -6. Is this ok ?
|
|
|
|
|
he probably should take the absolute value, and then apply it the original sign...
|
|
|
|
|
Rage wrote: d=-5.6 => i=-5, not -6. Is this ok ?
No, of course. I (naively) assumed d > 0 .
But there is an easy fix to account for negative numbers:
i = (int) ( d < .0 ? d -.5 : d + .5 );
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi everybody,
i put a ListControl on a dialog and want to catch the LVN_BEGINDRAG Handler.
I know that LVN_BEGINDRAG is a notify message.
I tried already :
ON_NOTIFY_REFLECT(LVN_BEGINDRAG,OnBeginDrag)
and via :
OnNotify(WPARAM w,LPARAM l, ...
{
if(((LPNMHDR)l)->code == LVN_BEGINDRAG)
int ok = 1; --> breakpoint
but i can't catch it
I tried also directly to add a handler via the ressource editor by adding a new handler,
but there i can't find the LVN_BEGINDRAG handler, only DoubleClick, Set & KillFocus ...
How should i catch it?
Big thanks
|
|
|
|
|
Try this:
ON_NOTIFY(LVN_BEGINDRAG, IDC_LISTVIEW1, OnLvnBeginDrag)
This should work.
"Some people believe football is a matter of life and death.
I'm very disappointed with that attitude.
I can assure you it is much, much more important than that. -- Bill Shankly"
|
|
|
|
|
Thanks for your answer
Is it necessairy to create a class from this Listbox from which i want to catch the Drag?
Because it won't work
|
|
|
|
|
|
Thanks for the tutorial,
but i really don't find where i can add the LVN_BEGINDRAG-handler via the classwizard.
I tried a lot of things, but no way to find a LVN_BEGINDRAG.
|
|
|
|
|
You may actually have to type it in by hand
For the handler prototype(s), see ON_NOTIFY and WM_NOTIFY Messages[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Insert this code to your program
BEGIN_MESSAGE_MAP(CDialogDlg, CDialog)
ON_NOTIFY(LVN_BEGINRDRAG, IDC_LIST2, OnLvnBeginrdragList2)
END_MESSAGE_MAP()
void CDialogDlg::OnLvnBeginrdragList2(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
*pResult = 0;
}
afx_msg void OnLvnBeginrdragList2(NMHDR *pNMHDR, LRESULT *pResult);
|
|
|
|