Solved

bitmpas loading..using SetTimer..

Posted on 2000-03-13
7
181 Views
Last Modified: 2013-11-20
hi,
i want to load  10 bitmaps.At the same position these bitmaps should come one after the other ..using SetTimer.it should form a loop.Bitmaps
are displayed full window..
0
Comment
Question by:b_harpal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Expert Comment

by:hiap_ho
ID: 2614853
define a timer
#define IDC_TIMER   1000

define a message map
afx_msg void OnTimer(bla bla bla)

then make your function in OnTimer

In your main application use SetTimer(blablabla) <--- to set how long you want to wait before loading the next function.

More detailed explaination could be found in http://devcentral.iftech.com/Learning/tutorials/mfc-win32/vc6mfc/5.asp


0
 

Accepted Solution

by:
krisp earned 30 total points
ID: 2615724
Hi b_harpal,

Say u have a dialog based application,
In the dialog .cpp class, do the following

************************************
 Use the "SetTimer(1, 500, NULL)"
function in the OnInitDialog() function of the dialog.
************************************
*In the OnPaint()function, under the else part of IsIconic()loop, add the following code
HDC hMemDC = ::CreateCompatibleDC(NULL);
      SelectObject(hMemDC, hbitmap);

::StretchBlt(dc.m_hDC, 50, 50, width,  hieght, hMemDC, width1, hieght1, 250,250, SRCCOPY);
//width,hieght,width1,hieght1
//are integers which determines the  
// size of the bitmap shown.
::DeleteDC(hMemDC);
::DeleteObject(hbitmap);


**************************************

In the OnTimer() function, use the following
static int i =1;
if(i == 1)
{
   hbitmap = ::LoadBitmap     (::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1));
}
else if(i == 2)
 {
     hbitmap = ::LoadBitmap(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP2));
}      
else if(i == 3)
{
      hbitmap = ::LoadBitmap(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP3));
}
else if(i == 4)
{
      hbitmap = ::LoadBitmap(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP4));
}
else if(i == 5)
{
      hbitmap = ::LoadBitmap(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP5));
            i = 1;
}

i++;
this->InvalidateRect(NULL);
*************************************
hbitmap is of type HBITMAP which should be declared as a class variable.
I have done it for 5 bitmaps with resource name ID_BITMAP1...... U can extend it to 10 bitmaps in the OnTimer function.

hope this will answer your question.

Cheers
0
 

Author Comment

by:b_harpal
ID: 2618359
hi Krisp,

  thanks for your answer.But somehow iam still not able to implement it fully.It's giving problems in the OnPaint() function.It would be kind of u if u can give the full code so that i can cross-check it & solve my problem. Your answer helped me solve 95% of my problem..
waiting for reply..

cheers..
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:hiap_ho
ID: 2618408
Why don't you try the following code to draw the bitmap. Hope it will help :
width = the width of your screen in pixels
height = the height of your screen in pixels

      CBitmap cbmp;
      cbmp.LoadBitmap(IDB_BITMAP);
      HBITMAP Bmp;
      Bmp=(HBITMAP)cbmp;
      
      BITMAP bm;
      GetObject(Bmp, sizeof(bm), &bm);
      CPaintDC dc(this);
      HDC memdc = CreateCompatibleDC(NULL);
      HBITMAP h = (HBITMAP)SelectObject(memdc, Bmp);
      StrectchBlt(dc,0,0,bm.bmWidth,bm.bmHeight,memdc,0,0,width,height,SRCCOPY);  
      SelectObject(memdc, h);

I don't have any intention to cross krips, just trying to help, krips I hope you don't mind.
0
 

Expert Comment

by:krisp
ID: 2619112
Hi b_harpal,

In the OnPaint() function, I used the following


CPaintDC dc(this);
int width = 150;
int hieght = 150;
int width1 = 0;
int hieght1 = 0;
HDC hMemDC = ::CreateCompatibleDC(NULL);
      SelectObject(hMemDC, hbitmap);
::StretchBlt(dc.m_hDC, 0, 0, width, hieght, hMemDC, width1, hieght1, 250,250, SRCCOPY);
::DeleteDC(hMemDC);
::DeleteObject(hbitmap);

If u want to increase the size, increase the values of width and hieght.

If u still have any problems,please be specific in ur problem(what error u r gettin?)and please do send queries if u have.

cheers.
0
 

Author Comment

by:b_harpal
ID: 2627860
hi krisp,
  ur simply expert..thanks.but i think u can help me much more.
iam making a HP-UX tutor as final year project.so please help me..i had to use animations,sounds..etc.it would be great help and kind of u if u could help me in some way..like providing me some links..hope u reply....if required u can mail me at bharpal@yahoo.com..once again thanks for ur support.

cheers
harpal
0
 

Author Comment

by:b_harpal
ID: 2627893
hi krisp,

this is my first time...i think there's some problem..it is showing 3 pts instead of 30..so please..check it out.
harpal
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 55
fizzArray2 challenge 1 112
post4 challenge 28 121
Thin secure Windows 10 5 116
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question