Solved

drawpicture problem

Posted on 1997-06-06
2
265 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
[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
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

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!

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 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