|
Hi Luc,
you are very kind.
I think that the problem is not in the string, in another case the StringBuilder work fine. The problem is in the Ptr.
hImage comes from:
[DllImport("justicr.dll")]
public static extern long JIImageFileOpen(out IntPtr hImageFile, [MarshalAs(UnmanagedType.LPStr)] StringBuilder szFileName, long bWrite);
[DllImport("justicr.dll")]
public static extern long JIImageFileRead(IntPtr hImageFile, out IntPtr hImage);
rc = (int)JIImageFileOpen(out hImageFile, fullname, 0);
rc = (int)JIImageFileRead(hImageFile, out hImage);
rc = (int)JIImageGetInfo(hImage, out IWidth, out IHeight, out IResolution, out IBytesPerLine, fileName, out iPage);
and it works because JIImageGetInfo works.
and hTemplateList from:
[DllImport("justicr.dll")]
public static extern long JITemplateListCreate(out IntPtr hTemplateList);
[DllImport("justicr.dll")]
public static extern long JITemplateListLoad(IntPtr hTemplateList, [MarshalAs(UnmanagedType.LPStr)] StringBuilder szTemplates);
rc = (int)JITemplateListCreate(out hTemplateList);
rc = (int)JITemplateListLoad(hTemplateList, listaCompleta);
which is for you the problem in JIMatchPage???
ty very much
|
|
|
|
|
Hi Alessio,
I didn't realize, you and I had an earlier dialogue, and my message then ended on "Now the tricky part could be what comes next: how will managed code access the content of the image?". So that is what we are trying to do now
As I already said above, I don't trust or don't like the out IntPtr stuff. Let me expand on that: either you have data allocated by the managed world and you want to pass it (or a pointer to it) to the native world, so you probably would need the fixed keyword and no IntPtr, or the GCHandle class and no out/ref keywords. Or the memory gets allocated by the native world, and then the managed world must somehow either (1) adopt the thing as if it were a managed object (which it is not), or (2) create an object and copy all the data (which I typically don't like). AFAIK you will need to call some of the Marshal methods explicitly, however I can't provide any details, I never did such things since most Win32 API calls don't need it, and when I can choose (because the native code is mine too) I keep the data marshaling simple and try to allocate objects always on the managed side.
"Now the tricky part could be what comes next: how will managed code access the content of the image?"
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:42 AM
|
|
|
|
|
I have a table layout control with buttons in it's cells, if you click a button, it is supposed to disappear by setting its Visible property to false and it works fine, however, when I try to reposition the buttons in the table and click on the buttons, they do disappear but dragging the next button in the next cell to fill it's place and leave the last cell of the table empty! Beforehand, it used to disappear leaving it's cell empty and somehow I dont seem to have this facility anymore!
Please help!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Ok, I solved it by setting controls size to Size(0,0) instead of hiding them, I know it's not a correct solution but it works fine with me!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
I have a project that dynamically displays the selected form/control in another Forms splitContainer panels, either left or right etc.
Problem I had when running this code was that the form/control within the splitContainer doesn't resize and get's cut-off when the main app resizes. This I fixed by calling the .Show() of the internal Form, BEFORE adding it to the splitContainer, now it resizes just fine! But since the control is being shown before it's done generating, it creates a flicker effect in which you can see for a millisecond how the controls are generated and placed, and it doesn't look very professional.
This was a mouthful, but if you understand where I'm coming from, and maybe know where I should go, please let me know!
I'd also like to mention that the Form containing the splitContainer is itself located within an MDI Parent.
Regards!
|
|
|
|
|
Try turning on double buffering for the form.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi all,
I used to build databases with MS Access and I need to learn SQL server 2008
what books do you recommend for SQL server 2008
|
|
|
|
|
|
hi,
how i can catch the processes of other types rather than .exe and .dll using c#?
Process[] p=Process.getprocesses();//return only .exe and .dll files
|
|
|
|
|
I don't understand, those are the processes that are running, what do you see differently when you press crtl-alt-del?
Other files, .doc, .jpg, .cs have an association with an executable to display the contents of those files, so they are not processes, but files that open a process to show their content.
|
|
|
|
|
you may get the hidden processes (windows services) by using:
ServiceController[] services = ServiceController.GetServices();
Calin
|
|
|
|
|
Hi all,
I need to split a SELECT QUERY fom a database (which i put in a DataTable) from this:
DataTable1
0
1
2
3
4
5
6
7
8
9
10
0
1
2
3
4
5
6
7
8
9
10
0
1
2
3
0
1
2
0
1
To this:
DataTable1
0
1
2
3
4
5
6
7
8
9
10
DataTable2
0
1
2
3
4
5
6
7
8
9
10
DataTable3
0
1
2
3
DataTable4
0
1
2
DataTable5
0
1
How can i do that??
|
|
|
|
|
It's less that 4 hours since you last asked this question.[^]
Was there something wrong with the coded example you were given there? Maybe you should try solving the problem yourself first, rather than expecting someone else to do it all for you?
It definitely isn't definatley
|
|
|
|
|
Hello,
How we can transform a Excel file to PDF?
thank you verry mutch.
|
|
|
|
|
|
Thank you verry mutch, but i need to transform an excel file and not a htm file, help me please, thank you verry mutch.
modified on Thursday, February 26, 2009 8:32 AM
|
|
|
|
|
You can write to a pdf file, even add images using PDFSharp:
<br />
XGraphics gfx2 = XGraphics.FromPdfPage(page2);<br />
gfx2.DrawRectangle(XPens.Black, XBrushes.LightGray, new XRect(40, 310, 500, 40));<br />
gfx2.DrawImage(XImage.FromFile(@"C:\image1.jpg"), new XRect(30, 30, 100, 107));<br />
<br />
But to graft an Excel file in a pdf! I have not found how to do, help me please, thank you very much
|
|
|
|
|
|
Thank you verry mutch for your help, i do like this :
<br />
static void Main(string[] args)<br />
{<br />
ApplicationClass excelApplication = new ApplicationClass();<br />
Workbook excelWorkBook = null;<br />
<br />
<br />
<br />
string paramSourceBookPath = @"C:\2.xlsx";<br />
object paramMissing = Type.Missing;<br />
<br />
string paramExportFilePath = @"C:\test.pdf";<br />
XlFixedFormatType paramExportFormat = XlFixedFormatType.xlTypePDF;<br />
XlFixedFormatQuality paramExportQuality =<br />
XlFixedFormatQuality.xlQualityStandard;<br />
bool paramOpenAfterPublish = false;<br />
bool paramIncludeDocProps = true;<br />
bool paramIgnorePrintAreas = true;<br />
object paramFromPage = Type.Missing;<br />
object paramToPage = Type.Missing;<br />
<br />
<br />
<br />
try<br />
{<br />
excelWorkBook = excelApplication.Workbooks.Open(paramSourceBookPath,<br />
paramMissing, paramMissing, paramMissing, paramMissing,<br />
paramMissing, paramMissing, paramMissing, paramMissing,<br />
paramMissing, paramMissing, paramMissing, paramMissing,<br />
paramMissing, paramMissing);<br />
<br />
if (excelWorkBook != null)<br />
excelWorkBook.ExportAsFixedFormat(paramExportFormat,<br />
paramExportFilePath, paramExportQuality,<br />
paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,<br />
paramToPage, paramOpenAfterPublish,<br />
paramMissing);<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine(ex.ToString());<br />
}<br />
finally<br />
{<br />
if (excelWorkBook != null)<br />
{<br />
excelWorkBook.Close(false, paramMissing, paramMissing);<br />
excelWorkBook = null;<br />
}<br />
<br />
if (excelApplication != null)<br />
{<br />
excelApplication.Quit();<br />
excelApplication = null;<br />
}<br />
<br />
GC.Collect();<br />
GC.WaitForPendingFinalizers();<br />
GC.Collect();<br />
GC.WaitForPendingFinalizers();<br />
} <br />
<br />
<br />
}<br />
But unfortunately, it doesn't work, help me please, thank you verry mutch.
|
|
|
|
|
|
the error was:
System.ArgumentException: The value is not within the range expected.
à Microsoft.Office.Interop.Excel.WorkbookClass.ExportAsFixedFormat(XlFixedFormatType Type, Object Filename, Object Quality, Object IncludeDocProperties, Object IgnorePrintAreas, Object From, Object To, Object OpenAfterPublish, Object FixedFormatExtClassPtr)
à Excel_to_Pdf.Form1.Form1_Load(Object sender, EventArgs e) dans C:\Documents and Settings\Administrateur\Mes documents\Visual Studio 2005\Projects\Excel_to_Pdf\Excel_to_Pdf\Form1.cs:ligne 53.
Thank you verry mutch
|
|
|
|
|
|
thank you verry mutch,it work for a xlsx file,but unfortunatelly not for xsl file, how i can resolve this problem? thank you verry mutch.
|
|
|
|
|
I tried your code with a xls file and it appears to work. It was an xls made with Excel 2007, though...
As usual, what is the error?
|
|
|
|
|
the error was :
System.Runtime.InteropServices.COMException (0x800A03EC): Exception de HRESULT : 0x800A03EC
à Microsoft.Office.Interop.Excel.WorkbookClass.ExportAsFixedFormat(XlFixedFormatType Type, Object Filename, Object Quality, Object IncludeDocProperties, Object IgnorePrintAreas, Object From, Object To, Object OpenAfterPublish, Object FixedFormatExtClassPtr)
à Excel_to_Pdf.Form1.Form1_Load(Object sender, EventArgs e) dans C:\Documents and Settings\Administrateur\Mes documents\Visual Studio 2005\Projects\Excel_to_Pdf\Excel_to_Pdf\Form1.cs:ligne 68
Thnak you verry mutch.
|
|
|
|
|