Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

drawpicture problem

Posted on 1997-06-06
2
Medium Priority
?
281 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 300 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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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 response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

783 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