Solved

drawpicture problem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now