|
usually if you are using worker and if you want to update GUI, then the best you can do is, just use SendMessage or PostMessage for GUI updation. otherwise it may to crashes, hope u dont want crashes
Else the suitable solution is use of UI thread, just refer [^]
Величие не Бога может быть недооценена.
|
|
|
|
|
Well.. thnx for the info it helped a lot. Now i am using UI-thread. And post messages to thread, etc. And it's all cool. It works. It creates the map of buttons and etc. BUT the problem hasn't been resolved. Buttons doesn't appear on the screen! They are created in memory but doesn't appear. Like i said the same trouble i had with pointers. I create pointer theApp.object = new CObject(...). Then theApp.object->Create(..) and theApp.object->ShowWindow(SW_SHOW) and it didn't show up. But if i write CObject globalobject; and then Create it, it appears correctly. I don't know how is that previously it worked with theApp.lvl = new ... but now it doesn't. But it all exists in the memory. I don't understand.
I noted that the objects actually works. I can click them, but the objects doesn't draw itselfs.
P.S. спасибо за ответ =)
modified on Monday, October 26, 2009 11:59 AM
|
|
|
|
|
I'm looking for some C++ code to let me quickly move a bitmap around a window, restoring the background as it moves. At present I capture the Window contents to a bitmap during the app initialization and in the OnPaint() I draw the this bitmap and then I draw my overlayed bitmap. I am double buffering the paint. The overlayed bitmap position moves with the mouse which invalidates the Window.
This works fine except it is too slow when the background window is large (think Windows Desktop) and the PC is slow. My guess is that redrawing the large background bitmap on every mouse move is the bottleneck. There has to be a much better and faster way to do this, but my searching hasn't found the answer I need.
modified on Sunday, October 25, 2009 5:25 PM
|
|
|
|
|
|
«_Superman_» wrote: Try writing a handler for WM_ERASEBKGND[^] and return non-zero.
Thanks, but I'm already doing that.
|
|
|
|
|
Try to redraw only parts on your window that really change instead of redrawing the whole thing.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
if the background is static, you really only need to draw the overlay at its new position and then draw the parts of the background that were uncovered when the overlay moved. there's no need to redraw the whole background.
1. the overlay's previous rect = R1.
2. the overlay's new rect = R2.
3. R3 = the bounding rect of R1 and R2.
4. alloc a bitmap of size R3
5. fill it with the appropriate chunk of background
6. draw the overlay into the temp bitmap
7. draw the temp bitmap to the screen
as long as the overlay is moving only a few pixels at a time, R3 should be just slightly bigger than the overlay size. if R1 and R2 don't instersect, you can split it into two operations: restore the background to one rect, then draw the overlay into the other - don't bother with the temp bitmap.
|
|
|
|
|
Thanks Chris, sounds like a good plan.
|
|
|
|
|
Load the image to memory and try to move it.
|
|
|
|
|
I am already using a memory buffer as I said at the start: "I am double buffering the paint."
|
|
|
|
|
Would you get better performance by using your current methods but using (say) DirextX or OpenGL to do the blitting? They might have better performing drivers that make better use of hardware?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks Stuart. I'd considered that but didn't want to add the overhead and complication of using these libraries. As of late yesterday I now have an implementation that works well enough on my slow old Vista Notebook and very well on my Desktop PC. Basically doing what Chris suggested.
|
|
|
|
|
Hi again,
Does anyone know a code so when the user presses the Escape key during the full screen mode in my Win32 project to exit the application just by pressing the button.
Thanks
Andrew McIntyre
|
|
|
|
|
Assing an accelerator key to VL_ESCAPE, and handle (eg) IDM_VIEW_CANCELFULLSCREEN.
Or hook up WM_KEYDOWN/VK_ESCAPE...
Basically, the same way as you'd handle someone pressing the 'A' key.
Enjoy,
Iain.
ps, I'm not touching the fullscreen bit, as I know you did all that yesterday. If you can switch into fullscreen, you can switch out.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
So how would that look like with in code.
Andrew McIntyre
|
|
|
|
|
MrMcIntyre wrote: So how would that look like with in code.
Well now that you know what the code looks like to maximize the window you should be able to figure out how to get it back to normal size.
|
|
|
|
|
Manage the use of electricity in a village (or ward)
1. Managing households in each village (data including: household owner, address, schools needed)
2. Manage the use of electricity in a month
3. Calculate the monthly electricity use of each household
4. Report payment of monthly electricity use
5. Handling violations (Interrupter, electric discharge back)

|
|
|
|
|
Uh, what a interesting project: good luck!
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]
|
|
|
|
|
*click*
Bad Question.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
If you do get help doing this, I trust you'll make a nice donation to a programming related charity?
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
thank you! forward to help!
|
|
|
|
|
dinh_vu_vt2005 wrote: Manage the use of electricity in a village (or ward)
I'd like the code for a program that did that. Then I could sell it to the government of Vietnam and make my fortune. 
|
|
|
|
|
Do you want any fries with that?
"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
|
|
|
|
|
In my MFC program the int 10 (ten) is treated as binary 10 (one & zero) i.e. == 2.
So when I insert any item at 10th position then it is inserted at 2nd position.
Similarly for 100th item it is inserted at 4th position.
My program is a Dialog Based Application.
m_ctlDeviceList is control variable for ListCtrl and it is set in Report View.
void CIPMDlg::OnBnClickedBrefreshdevices()
{
int field0 = 0, field1 = 0, field2 = 0, field3 = 0;
int c=0, nIndex=0;
CString ips = _T("");
for (field0 = 192; field0 <= 192; field0++)
{
for (field1 = 168; field1 <= 168; field1++)
{
for (field2 = 0; field2 <= 255; field2++)
{
for (field3 = 0; field3 <= 255; field3++)
{
ips.Format(_T("192.168.%u.%u"), field2, field3);
nIndex = m_ctlDeviceList.InsertItem(c, ips);
m_ctlDeviceList.SetItemText(nIndex, 1, _T("Testing"));
c++;
}
}
}
}
}
Why is this happening?
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
Manmohan29 wrote: In my MFC program the int 10 (ten) is treated as binary 10 (one & zero) i.e. == 2.
This is definitely not true.
I think the problem may be that your ListCtrl is automatically sorting the entries as you add them. So you add "192.168.0.0", "192.168.0.1" etc. Then when you insert "192.168.0.10" it will be inserted in position 2 between "192.168.0.1" and "192.168.0.2". It may be better to ensure that you format the numbers with 3 digits in every case, or turn off the auto sort feature of the ListCtrl.
|
|
|
|