Solved

drawpicture problem

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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