|
The UI would appear to be frozen because your application is busy processing roger() function. One way (from the book: "Ugliest things to do") is to do the dirty stuff manually, but I said it is dirty.
Put this within your while loop:
MSG Msg;
while(::PeekMessage(&Msg, NULL, 0, 0, PM_NOREMOVE))
{
AfxPumpMessage();
}
I've assumed you're using MFC, if you're not, you can still call up on TranslateMessage and DispatchMessage (which would make it dirtier)
This would manually pump message during every iteration of the loop and your application's UI won't appear frozen. *BUT*, you must do such things on a separate thread, like everyone else said.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: you must do such things on a separate thread, like everyone else said.
Ummm, no, I did not.
In fact I said the opposite based on what it seems like he's trying to do.
His whole while-loop is an attempt to create timer-functionality and "count seconds".
He'd better correct the root cause and use a timer instead of still doing the wrong thing, but disguising it in a thread.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
OK, boo me. I must read the whole thing carefully before replying.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
lol I just did the same.. looking at the loop he had put, I just replied him to go ahead with a worker thread.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Hi,
I have created SDI application from CView base class, Now I want to type charactors on the client area. But it was derived from CView so i couldn't get control. So I have created one CRichEditView class object. But i dont know to create the RichEditView for the currently active window. Pls help me
|
|
|
|
|
Ummm - why not just change your custom view to derive from CRichEditView ? You'll also have to replace CView with CRichEditView in various places in your view's .cpp file, for example, in an IMPLEMENT_DYNCREATE statement, a BEGIN_MESSAGE_MAP statement and where CView methods are called (e.g. your view's PreCreateWindow method will call CView::PreCreateWindow - that should be changed to CRichEditView::PreCreateWindow ).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I what to inherit the struct from another struct in IDL file
any idea?
|
|
|
|
|
Gopal_Kanchana wrote: any idea?
Yes.
Hint: Goooooogle is sooooooooooooo powerful ^ (third item looks promising...).
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I didn't get your reply. Please clarify in detail
|
|
|
|
|
Gopal_Kanchana wrote: I didn't get your reply. Please clarify in detail
Using Google will make you a developer with superpowers...
Click the link I provided, in the 'Hint' at the bottom of my previous reply.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
i'm new to c preprocessor and i would like to do some string replacement in a text file using c preprocessor.
the code is something like this
---
#define __TOREPLACE__ replaced
path/subpath/__TOREPLACE__
path\__TOREPLACE__image.png
---
the output is:
...
path/subpath/replaced
path\__TOREPLACE__image.png
...
as seen, there is a replacement in the first path, but not in the second one.
why isn't the second one replaced ?
is this a good approach at all ?
thanks in advance
|
|
|
|
|
Just a guess... But try it with a double \\. In C files, a single \ means the next character has something special about it. Well, it quoted strings it does!
And as your paths aren't valid commands or variable names, I'm guessing you left out the rest of the line and the quotation marks?
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
thanks for your answer, Iain.
i've already tried using the double backslash, but no real effect.
the code i've posted is only seen as an example.
the text files i would like to be preprocessed are no real c code,
more like text conf files, where some text variables have to be replaced.
|
|
|
|
|
I've already given you an answer - but with this extra information...I'd suggest you might be better off using something other than the C pre-processor. awk, m4, perl? They're all available using something like gnuwin32[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I guess the macro should be modified as follows
#define __TOREPLACE__ "replaced"
and used like
"path/subpath/"__TOREPLACE__
"path\"__TOREPLACE__"image.png"
|
|
|
|
|
thanks Naveen, but unfortunately,
the result is not what i wanted.
"path/subpath/""replaced"
"path\"__TOREPLACE__"image.png"
|
|
|
|
|
tarcairion wrote: "path\"__TOREPLACE__"image.png"
you should put double slashes...
"path\\"__TOREPLACE__"image.png"
|
|
|
|
|
The C pre-processor is seeing __TOREPLACE__image.png as a single identifier. That identifier isn't __TOREPLACE__ , so it doesn't replace it.
If you want to 'glue' a replaced value to some static text, you'll need something like this:
#define GLUE2(A, B) A##B
#define GLUE(A, B) GLUE2(A,B)
#define __TOREPLACE__ replaced
path/subpath/__TOREPLACE__
GLUE(path\,GLUE(__TOREPLACE__,image.png))
That works OK under the VC++ pre-processor, giving this output:
path/subpath/replaced
path\replacedimage.png
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thank you for your answer, Stuart. this works, indeed.
i seems to be that the preprocessor has some difficulty
to identify a #define in some places due to missing
delimiters
but as you stated it may not be the best approach, so
i will try something else like you mentioned.
|
|
|
|
|
Hi there.
We have some stored procedures on a remote SQL Server.
Now, from my local machine using C++ I want to call a stored procedure.
Please provide sample code if available for the same.
Incase any further information required, please let me know.
Thanks and Regards
PanB
|
|
|
|
|
Let's me try to use Google for you...^
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
I have made a dialog based application in vc-2008. I have made 2 more dialog boxes...
Now what i have to do is on button click event 1st dialog box is called, so first dialog box OnInitDialog function is being called in that function second dialog box DoModal function has been called... Now what i want is if second dialog box return 1 i.e its successful then only first dialog box should be constructed and do its processing otherwise it should not be constructed.....
for example
CFirstDialog dlg;
dlg.DoModal();
BOOL CFirstDialog::OnInitDialog()
{
CSecondDialog dlg1;
int ret_val = dlg1.DoModal();
if(ret_val == 1)
return true;
else
return false;
}
but this code is not solving my problem...
its giving me a dialog box(first) in not working condition....
how to do this....
can anybody help me in this...
thanks in advance
|
|
|
|
|
Why do you want to do that in the OnInitDialog from CFirstDialog ? Can't you simply move the condition check at the place where you create CFirstDialog originally ? There you first create CSecondDialog and if the return condition is not what you expect, then you don't create CFirstDialog. Seems a bit better than putting that in the OnInitDialog...
|
|
|
|
|
Cedric's answer is good - you're testing too late. Why go to all the bother of making a dialog then throwing it away?
Saying that, you may have a very good reason.
So...
As you're a VCProgrammer, you should be familiar with documentation. OnInitDialog / WM_INITDIALOG has some too. Here's an extract:
Return Values
The dialog box procedure should return TRUE to direct the system to set the keyboard focus to the control specified by wParam. Otherwise, it should return FALSE to prevent the system from setting the default keyboard focus.
You don't get to make up the meaning of returns values for messages you didn't invent. Otherwise windows programming would be a whole lot more... interesting...
I'm pretty sure you can call EndDialog from within OnInitDialog though, which would give you a hacky answer - but Cedric's solution would be a lot cleaner.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
modified on Thursday, February 12, 2009 5:05 AM
|
|
|
|
|
just call EndDialog() instead of return false;// dialog should not be created
aks
|
|
|
|