Solved

drawpicture problem

Posted on 1997-06-06
2
246 Views
Last Modified: 2013-12-26
when I compile this code segement that is jsut a test to show a splash screen at launch I get A window in the proper place but now picture drawn in it.  This code used to work fine unitl I upgraded to codewarrior 11 with the MSL libraries.
/*•••••••••••••••••••••••••••   Mac Includes   •••••••••••••••••••••••••••••••••••••••••••*/
#include <Types.h>
#include <AppleEvents.h>
#include <Dialogs.h>
#include <Editions.h>
#include <Events.h>
#include <Fonts.h>
#include <Menus.h>
#include <SegLoad.h>
#include <TextUtils.h>
#include <ToolUtils.h>
#include <Windows.h>
#include <QDOffscreen.h>
#include <Devices.h>
#include <Quickdraw.h>
/*••••••••••••••••••••••••••   QD3D Includes   •••••••••••••••••••••••••••••••••••••••••••••*/
#include <QD3D.h>
#include <QD3DAcceleration.h>
#include <QD3DCamera.h>
#include <QD3DDrawContext.h>
#include <QD3DErrors.h>
#include <QD3DGeometry.h>
#include <QD3DGroup.h>
#include <QD3DIO.h>
#include <QD3DLight.h>
#include <QD3DMath.h>
#include <QD3DPick.h>
#include <QD3DRenderer.h>
#include <QD3DSet.h>
#include <QD3DShader.h>
#include <QD3DStorage.h>
#include <QD3DString.h>
#include <QD3DStyle.h>
#include <QD3DTransform.h>
#include <QD3DView.h>
/*••••••••••••••••••••••••••••   Prototypes  •••••••••••••••••••••••••••••••••••••••••••••••*/
void initstuff (void);
void main (void);
void inittoolbox (void);
/*•••••••••••••••••••••••••••   Globals   ••••••••••••••••••••••••••••••••••••••••••••••••••*/
Boolean                                    done;
Boolean                                    inbackground;
WindowPtr                              tools;
WindowPtr                              top;
WindowPtr                              front;
WindowPtr                              right;
WindowPtr                              camera;
WindowPtr                              world;
WindowPtr                              bar;
WindowPtr                              about;
/*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
void inittoolbox ()
{
      InitGraf(&qd.thePort);
      FlushEvents ( everyEvent, 0);
      InitFonts();
      InitWindows();
      InitMenus();
      TEInit();
      InitDialogs(nil);
      InitCursor();
}
/*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
void initstuff ()
{
      WindowPtr            splashscreen;
      PicHandle            startpic;
      Rect                  picrect;
      GDHandle            thescreen;
      Rect                  boundsrect;
      Point                  screencenter;
      short                  left;
      short                  Top;
      
      inittoolbox();

      boundsrect.right = 640;
      boundsrect.bottom = 480;
      boundsrect.top = 0;
      boundsrect.left = 0;
      splashscreen = NewCWindow(      NULL,
                                                &boundsrect,
                                                "\pnothing",
                                                FALSE,
                                                plainDBox,
                                                ( WindowPtr )-1L,
                                                FALSE,
                                                0);
      startpic = GetPicture(129);
      SetRect(&picrect,0,0,640,480);
      thescreen = GetMainDevice();
      boundsrect = (**(thescreen)).gdRect;
      screencenter.h = (boundsrect.right/2);
      screencenter.v = (boundsrect.bottom/2);
      left = screencenter.h - 320;
      Top = screencenter.v -240;
      MoveWindow(splashscreen, left, Top, true);
      ShowWindow(splashscreen);
      SetPort( splashscreen );
      DrawPicture(startpic, &picrect);
      
      done = false;
      while(!done)
            {
                  DrawPicture(startpic, &picrect);
            }
}
/*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
void main ()
{
      initstuff();
}

Any help would be apriciated?

Jarrett Miller
CEO. Glass Coffin Software
manson61@ix.netcom.com
0
Comment
Question by:masnon
2 Comments
 
LVL 1

Accepted Solution

by:
Paul B earned 100 total points
ID: 1291493
In your display loop you should not call DrawPicture repeatedly. This can cause some very strange things to happen. You should change the loop to
done = false;
while (!done)
{
   done = Button();
}
This will exit the loop when you click the mouse.

Another change that you should do is to add error checking when you get the picture:

startpic = GetPicture(129);
if (!startpic)  DebugStr("\pCould not get picture 129");


When I made those changes to my project (using CW11 AND Pro) it worked fine. It scales my picture to 640 x 480 and draws it centered on the screen. If you don't want your picture scaled you should use the pictures rectangle (*startpic)->picFrame.

Paul Baxter
pbaxter@assistivetech.com


0
 

Author Comment

by:masnon
ID: 1291494
thank you
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 201
Folder Comparison 12 54
string initialization in java 11 114
matchUp  challenge 6 64
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

821 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