|
termal wrote: now i like to recive a cookie if posible from this url, how to do this?
Try InternetGetCookie() .
"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
|
|
|
|
|
Hello,
thanks for reply, i try to use this funktion!
regards
termal
|
|
|
|
|
the scenario is I am counting down 5, if no 'y' has been input during this time, then it ends at one way, else it ends at another way. Because I dont expect there must be a 'y' input, I write this as multi-thread, one for counting down, one for checking the 'y' input (could be unnecessary).
this program works fine when I put it at the foreground(using linux), but when put it at background, error happens, it will stop and wait for getchar() input, and m doesnot count down. As long as I use shell command "fg" to bring it back to foreground, the count down resumes, but that is not what I want.
what I want is just: put the program execution at background, while waiting for a 'y' input during 5 seconds count down time.
<br />
void *countdown( );<br />
void *waitinput( );<br />
static int m=5;<br />
static int k=1;<br />
<br />
int main(int argc, char **argv)<br />
{<br />
<br />
pthread_t thread1=0, thread2=0;<br />
int iret1=0, iret2=0;<br />
<br />
<br />
<br />
iret1 = pthread_create( &thread1, NULL, countdown, NULL);<br />
iret2 = pthread_create( &thread2, NULL, waitinput, NULL);<br />
<br />
<br />
<br />
<br />
<br />
pthread_join( thread1, NULL);<br />
<br />
pthread_cancel(thread1);<br />
pthread_cancel(thread2);<br />
printf("pthread been cancelled\n\n");<br />
<br />
if(k=1){...}<br />
else {...}<br />
<br />
<br />
return 0;<br />
}<br />
<br />
void *countdown()<br />
{<br />
while(m>0)<br />
{<br />
printf("%d seconds left\n",m--);<br />
sleep(1);<br />
printf("m is %d\n",m);<br />
}<br />
<br />
}<br />
<br />
void *waitinput()<br />
{<br />
char c='n';<br />
while(m)<br />
{<br />
if((c=getchar())=='y')<br />
{<br />
printf("congratulations. you entered y\n");<br />
sleep(1);<br />
m=0;k=0;<br />
}<br />
else ;<br />
}<br />
}<br />
|
|
|
|
|
bloodwinner wrote: pthread_create( &thread1, NULL, countdown, NULL);
A stab in the dark, since I do not know anything about Linux, but maybe you need to set one of these to something else than just NULL to get it to act independently of having or not the focus.
|
|
|
|
|
thank you for reply.
1.I guess it does not have much thing to do with the platform.
2.Regarding to the parameters of pthread, I took reference from here http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html#BASICS
it looks working fine, at least as I said when executing it at the foreground,
but because I can open only one terminal, probably have to do several things, so I can only put it running at the background, there problems occurs.
|
|
|
|
|
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"
|
|
|
|
|