Hardcore crash with C-API and rendering to Bitmap

Hi,

i have tested the program editfax.c but my notes crashed very hard with the window nsd is running. I need your help, because I dont know how to solve this problem.

The c-function that will crash notes is:

error = EditorPrintNoteToBitmap(hSourceDB,

           SourceNoteID,

           &EPBContext);

The logging file will I here post:

Protocol Stats:

===============

IPv4-Statistik

Empfangene Pakete = 6169

Empfangene Vorspannfehler = 0

Empfangene Adressfehler = 37

Weitergeleitete Datagramme = 0

Empfangene unbekannte Protokolle = 0

Empfangene verworfene Pakete = 0

Empfangene bermittelte Pakete = 6140

Ausgabeanforderungen = 3947

Verworfene Routingpakete = 0

Verworfene Ausgabepakete = 0

Ausgabepakete ohne Routing = 0

Reassemblierung erforderlich = 0

Reassemblierung erfolgreich = 0

Reassemblierung erfolglos = 0

Erfolgreiche Datagrammfragmentierung = 0

Erfolglose Datagrammfragmentierung = 0

Erzeugte Fragmente = 0

ICMPv4-Statistik

                        Empfangen Gesendet

Meldungen 3 3

Fehler 0 0

Ziel nicht erreichbar 3 3

Zeitberschreitung 0 0

Parameterprobleme 0 0

Quelldrosselung 0 0

Umleitungen 0 0

Echos 0 0

Echoantworten 0 0

Zeiteintr„ge 0 0

Zeiteintragantworten 0 0

Adressmasken 0 0

Adressmaskenantworten 0 0

TCP-Statistik fr IPv4

Aktiv ge”ffnet = 87

Passiv ge”ffnet = 4

Erfolglose Verbindungsversuche = 15

Zurckgesetzte Verbindungen = 4

Aktuelle Verbindungen = 1

Empfangene Segmente = 1841

Gesendete Segmente = 1636

Erneut bertragene Segmente = 30

UDP-Statistik fr IPv4

Empfangene Datagramme = 3035

Keine Anschlsse = 1255

Empfangsfehler = 0

Gesendete Datagramme = 2266

INFO (0): terminated process [ NLNOTES:0edc]

INFO (0): terminated process [ntaskldr:0814]

INFO (0): Deleting pid.nbf

WARNING (0): Debugger still attached to 2 processes

Started at: Tue Apr 12 12:06:26 2005

Ended at: Tue Apr 12 12:06:35 2005

Generated Messages:

INFO (0): Using PSAPI DLL

INFO (0): Found 3 Notes processes, matched 2

INFO (0): failed to match all of the Notes processes

INFO (0): Starting Debugger

INFO (0): Walk mem for process NLNOTES (edc)

INFO (0): Walk mem for process ntaskldr (814)

INFO (0): terminated process [ NLNOTES:0edc]

INFO (0): terminated process [ntaskldr:0814]

INFO (0): Deleting pid.nbf

WARNING (3): can’t get process 249298944 status

WARNING (0): Debugger still attached to 2 processes

ERROR (0): exception(0): thread 9ec got system exception: ACCESS_VIOLATION (3221225477)

Please send the following files:

            NSD Log : C:\Programme\lotus\notes\data\IBM_TECHNICAL_SUPPORT\nsd_all_W32I_MKRUEGER_04_12@12_06.log

Subject: Hardcore crash with C-API and rendering to Bitmap

Does it crash with every document and form? You might want to try a very simple form with a very simple document and make sure your program is working with that, then gradually increase the complexity. For example, if you have radio buttons or combo boxes, you may well crash, but you could determine what the problem is by gradually adding content. Also, if it didn’t work with even the simplest form and data, you would know you had a problem with your code.

Subject: RE: Hardcore crash with C-API and rendering to Bitmap

Hi,thx for your response. I have taken a very simply form, and now, I execute the program as DOS-Programm. Here I get the error, that a special database-object cannot be found after rendering. Rendering have a error, and something cannot be found that is necessay to render.

I hope, somebody can maybe say, what that means and what is missing.

Marc

Subject: RE: Hardcore crash with C-API and rendering to Bitmap

i’ve used this function once. as far as i can remember there has been some kind of tech note about that issue. it was something like a missing default view or default form, but i’m not really sure, check if that helps.

found it in capi-docu:

“Note that the database hosting the note must have a default view; otherwise, this API will give a “floating point not loaded” error.”

but that error is just a joke. sample programs main-functions returns a notes-error to windows:) took me a while to find out anything about those funny errors in notes…

one more thing: don’t wonder if this function crashes on some “special” documents, it definitly will. best approach to take is to use latest release you can find.

Markus Seitz

markus.seitz@icodex.com

Subject: RE: Hardcore crash with C-API and rendering to Bitmap

Hi Markus,

I’ve found a litte more about this problem. In using it as a standalone application it will work fine and all is very fine. I can call it with lotus-script in using the shell-execution, and it will fine too. But when I am calling it as dll-function it crashed in using the function EditorPrintNoteToBitmap. Maybe I make a error in defining a dll? But I can call other functions of this dll, and all works fine. Have I made a error?

Regards

M.Krueger

Subject: RE: Hardcore crash with C-API and rendering to Bitmap

so you got same document, one time it crashes, other not?

since it’s your dll it’s easy to debug it. use debug solution and set executable program to nlnotes.exe. set a breakpoint to that function, launch notes with vs. run script and debug.

maybe post source-snippets here, lscript define, call,…

Markus Seitz

markus.seitz@icodex.com

Subject: RE: Hardcore crash with C-API and rendering to Bitmap

Hi,thx for your response. Its hard to find out, what is happened. The code is same in the dll and in the standalone application.

Here is the code:

STATUS near PASCAL FaxDocument (NOTEID SourceNoteID)

/* FaxDocument - Test the FAX APIs on a single document

  • Inputs:

  • SourceNoteID = NoteID of document to be FAXed.

  • Outputs:

  • (Routine) = Error status

*/

{

STATUS error=NOERROR;

// NOTEHANDLE hSourceNote;

HBITMAP hPrevBitmap;

HBRUSH hBrush, hPrevBrush;

RECT Rect;

// char Buffer[256];

/* Create the target document to which the bitmaps will

    be appended */

if (error = NSFNoteCreate(hTargetDB, &hTargetNote))

  return(error);

/* Initialize the device parameters */

memset(&EPBContext, 0, sizeof(EPBContext));

/* Set up the resolution parameters */

EPBContext.cxPaperTwips = (DWORD) (WIDTH * ONEINCH);

EPBContext.cyPaperTwips = (DWORD) (HEIGHT * ONEINCH);

EPBContext.BitmapSize.width = 5085;//(DWORD) (WIDTH * DPI);

EPBContext.BitmapSize.height = 6005;//(DWORD) (HEIGHT * DPI);

/* Set up pointer to callback routine */

EPBContext.Proc = (EPBPROC) ProcessBitmap;

/* Creates a memory device context compatible with the

    application's current screen.  */  

EPBContext.hPaint = CreateCompatibleDC(NULL);

printf(“CreateCompatibleDC”);

if (!EPBContext.hPaint)

  {

  printf("Cannot create memory DC\n");

  NSFNoteClose(hTargetNote);

  return(NOERROR);  

}

/* Create a bitmap */

EPBContext.hBitmap = CreateMonochromeBitmap(EPBContext.hPaint,

                       EPBContext.BitmapSize.width,

                       EPBContext.BitmapSize.height);

/* Preset the bitmap to BLACK with a 10-pixel border and set the

   subset paint rectangle so that we can test to see that printing

   to a subset rect is working. */

hPrevBitmap = (HBITMAP) SelectObject(EPBContext.hPaint,

                                    (HANDLE)EPBContext.hBitmap);

Rect.left = Rect.top = 0;

Rect.right = EPBContext.BitmapSize.width;

Rect.bottom = EPBContext.BitmapSize.height;

// hBrush = CreateSolidBrush(0x02000000L | (RGBVALUE_BLACK));

 hBrush = CreateSolidBrush((RGBVALUE_BLACK)); 

hPrevBrush = SelectObject(EPBContext.hPaint, hBrush);

PatBlt(EPBContext.hPaint, (&Rect)->left,

           (&Rect)->top,                                                 

           (&Rect)->right-(&Rect)->left,          

        (&Rect)->bottom-(&Rect)->top,  

           PATCOPY); 

SelectObject(EPBContext.hPaint, hPrevBrush);

SelectObject(EPBContext.hPaint, (HANDLE)hPrevBitmap);

EPBContext.PaintRect.top = EPBContext.PaintRect.left = 10;

EPBContext.PaintRect.right = EPBContext.BitmapSize.width - 10;

EPBContext.PaintRect.bottom = EPBContext.BitmapSize.height- 10;

/* Print the note to the bitmaps */

printf(“Printing note %lX to bitmap…\n”,SourceNoteID);

printf(“Versuche nun rendering”);

error = EditorPrintNoteToBitmap(hSourceDB,

           SourceNoteID,

           &EPBContext);

/* Clean up. */

printf(“Lösche memory-allocation”);

Subject: RE: Hardcore crash with C-API and rendering to Bitmap

who do you call it from script? declaration something like ( Byval NoteID As Long )?

where does hTargetDB come from?

why not try to debug that thing? or at least do some logging inside your function.

Markus Seitz

markus.seitz@icodex.com

Subject: Well since the code you used is right out of the API Example…

I would suggest looking in the page Callback Function: EPBContext.Proc = (EPBPROC) ProcessBitmap;

Subject: RE: Well since the code you used is right out of the API Example…

Hi,

I have looked in the editfax-example and the code is the same in this callback-function. Now, my dll print out the document but then my Note dont crash, but it hang on and shows now reaction if I want to use it more. It seems that there is a memory problem with one variable. I hope I can find it out.

Subject: RE: Well since the code you used is right out of the API Example…

i hangs? that sounds quite strange. if you like you can send me source and i’ll have a look.

Markus Seitz

markus.seitz@icodex.com

Subject: RE: Well since the code you used is right out of the API Example…

Hi Markus,

I’ve send you my code snippet. I hope you will find the error.

Regards

MK

Subject: Solution?

can you PLEASE post your solution here?

thanx