|
Is there any way to do this without descending into unmanaged land? I'm using pure C# here. If not, teach me please?
Regarding placement, I can probably just set the width and height to zero.
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
No problem.
First of all, you need to add WebBrowser support to your project. Right click on the toolbox and select Customize toolbox... On the tab page click Browse... and open shdocvw.dll which is located in the windows\system32 folder.
Now you can draw the control on your form.
The next thing which you must do it to load the document which you want to print.
Object missing = System.Reflection.Missing.Value;
axWebBrowser1.Navigate( "http://www.codeproject.com", ref missing,
ref missing, ref missing, ref missing);
Print
axWebBrowser1.ExecWB( SHDocVw.OLECMDID.OLECMDID_PRINT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref missing, ref missing );
PageSetup
axWebBrowser1.ExecWB( SHDocVw.OLECMDID.OLECMDID_PAGESETUP,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref missing, ref missing );
PrintPreview
axWebBrowser1.ExecWB( SHDocVw.OLECMDID.OLECMDID_PRINTPREVIEW,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref missing, ref missing );
But be careful. The functions will fail if the document is not fully loaded. You can determine this thorugh NavigateComplete event.
And that's all. If you've got any question simply post it.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
This works great, with one problem that I just need a little clarification on to fix. I get an exception the first time I try to do anything with this code, and I guessed that this is because the document is not fully loaded until then, like you said. Now I'm trying to do something like this:
void PrintOperation(EventHandler operationToDo)
{
this.printingBrowser.NavigateComplete2 += operationToDo;
}
And have the EventHandler that's passed to PrintOperation do something like
axWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPREVIEW, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref missing, ref missing);
The problem is, it isn't letting me subscribe a vanilla EventHandler to the weird type of event handler NavigateComplete2 is. So, my question is, how could I fire a function upon completion of the navigation?
Thanks so much, this solution is absolutely perfect.
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
You're saying that you can't subscribe EventHandler which is invoked after a page is fully loaded, am I right. Or are you asking for something else?
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Well, what I'm saying is that my program is throwing an exception the first time I call ExecWB after a Navigate. I assume this is because the page isn't fully loaded, as you noted above. So:
How can I call a function when the page is loaded? I don't care how this is done -- an EventHandler, an NavigateComplete2 event, whatever.
Alternatively, if I'm wrong on why the exception is being thrown, tell me how to fix it.
Thanks!
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
I've got an idea. Make a class variable of type OperationToDo
private enum OperationToDo
{
Print = 1,
Preview = 2,
PageSetup = 3,
None = 4,
}
private OperationToDo m_eOperationToDo;
In the PageSetup function set the variable to the appropriate value, in this case PageSetup.
private void PageSetup()
{
m_eOperationToDo = OperationToDo.PageSetup;
LoadPage();
}
In the NavigateComplete2 EventHandler check what operation was launched and invoke it.
private void NavigateComplete2 ( ... )
{
if ( m_eOperationToDo == OperationToDo.PageSetup )
else if ( ... )
m_eOperationToDo = OperationToDo.None;
}
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Thanks so much for your help. If your interested, here's my solution:
private void DoPrintOperation(SHDocVw.OLECMDID operation)
{
this.printOperation = operation;
object missing = Missing.Value;
this.printingBrowser.Navigate(tempFilename2, ref missing, ref missing, ref missing, ref missing);
}
private void printOperationEventHandler(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
{
object missing = Missing.Value;
this.printingBrowser.ExecWB(this.printOperation, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref missing, ref missing);
}
Then in my event handlers, I have these code snippets:
this.DoPrintOperation(SHDocVw.OLECMDID.OLECMDID_PRINT);
this.DoPrintOperation(SHDocVw.OLECMDID.OLECMDID_PRINTPREVIEW);
this.DoPrintOperation(SHDocVw.OLECMDID.OLECMDID_PAGESETUP);
Pretty elegant!
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
I have made a downloader in C# where several threads retrieve data simultaneously.
The real problem is that it takes 90%-99% of the CPU time. It is not that my CPU is slow, but I have mistaken something.
I put the threads priority to the lowest and it is still the same.
I profiled the app and it said that most of the time is spend in the actual retrieving of data... But this should not be CPU intensive.
Does someone have any ideas?
|
|
|
|
|
Rincewind wrote:
I put the threads priority to the lowest and it is still the same.
Lowest priority only means that it won't try to steal CPU time from other threads/applications that want it; if your application is the only one trying to use the processor then it will get the processor.
Without any code I cannot make any assumptions as to why it is using that much of the processor.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
you are prob. going round a loop...
have a look at BITS
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
hi all i want to make a video conferencing application using .net frame work. Can anyone help me out if the beta version has any limitation and Java Media Frame work is a better option to opt for???
Thanku all
|
|
|
|
|
I'm interested in making an app with Video Conferencing too.
Could you tell me where I can find NetMeeting SDK or other reference.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Hi,
We're getting this error when calling Assembly.GetTypes on one of our libraries. There appears to be no obvious difference between it and another similar library for which the call works.
Google/Deja shows a number of people having this problem but no real answers, many seem to be related to problems with the beta and release versions of .NET which won't be our problem.
Has anyone got a solution to this?
Thanks,
Jason.
modified 10-Jul-19 21:02pm.
|
|
|
|
|
IIRC this is caused because the assembly references another assembly; but that assembly hasn't been loaded yet.
Have you tried searching the DOTNET, ADVANCED-DOTNET, and DOTNET-* list archives?[^]
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Iam recompiling a VC6 project in .NEt which contains std::vector
typedef CArray<double,const double&=""> CDoubleArray;
typedef Point<double> DoublePoint;
class CPointVector : public vector<doublepoint>
{
public:
CPointVector( CDoubleArray& rZ, CDoubleArray& rX );
CPointVector( CPointVector& rPointVector );
void ExportToDoubleArrays( CDoubleArray& rZ, CDoubleArray& rX );
};
CDoubleArray rZ;
CDoubleArray rX;
CPointVector PointVector( rZ, rX );
.
.
.
.
the following line gives the compile error below
DoublePoint* pVectorEnd = PointVector.end( );
C2440: 'initializing' : cannot convert from 'std::vector<_Ty,_Ax>::iterator' to 'DoublePoint *'
with
[
_Ty=DoublePoint,
_Ax=std::allocator<doublepoint>
]
Why does this error occurr in .NET and is there a solution
|
|
|
|
|
The C++ compiler in .NET has some, er, features, which bring it much closer to the ANSI standard than VC6. This means that you have to be much more careful how you cast. in this case iterators to pointers.
Found the following note in the VC7 docs.
*************************************************************
Visual C++ Concepts: Porting and Upgrading
Some Iterators Are No Longer the Same as PointersSee Also
Breaking Changes in the Standard C++ Library
In some Standard C++ Library classes, iterators are no longer defined as pointer types.
The following sample compiled in Visual C++ 6.0, but fails on the indicated lines in the current version:
#include <string>
#include <vector>
#include <algorithm>
bool pred(int i) {
return true;
};
void main()
{
std::string str("test");
const char *pszstr = str.begin(); // LINE 8: INCORRECT
const char *pszStr2 = str.c_str(); // OK
const char *pszStr3 = &(*str.begin()); // OK
std::vector<int> v;
int *pint = std::remove_if(v.begin(), v.end(), pred); // LINE 13: INCORRECT
std::vector<int>::iterator iint = std::remove_if(v.begin(), v.end(), pred); // OK
}
*****************************************
hope this helps
Adam.
P.S. know what you mean about .net. Just installed it and 50% of my apps now crash
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
if i have hwndle (HWND)of parent window and hwndle of child window then how to get the point and rectangle of child window with respect to its parent window ?
r00d0034@yahoo.com
|
|
|
|
|
When I compile my application using VC++ 6.0, my app requires MFC42.DLL, while if compiled with VC++.net, is requires MFC70.DLL
Is there a way to compile using .net AND forcing it to link to MFC42.DLL and not MFC70.DLL ???
PLEASE help.
Rick Eastes.
------------
Rick Eastes.
------------
|
|
|
|
|
Yes, set the projects include and lib directories to point to the VC6 directories. It will use the projects directories first before the global ones.
Change the "Debug Information Format" to just "Program Database". MFC42 doesn't like the new edit and continue. They changed something internally.
Make sure the "Basic Runtime Checks" is set to "Default".
There might have been some more settings I changed when I tried this myself, but I deleted the project and went back to the VC6 environment since the edit & continue didn't work.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
Hi I'm very new to .net and would like to know the following...
I've been told that .net apps can be run on unix/linux - is that true? if so how?
I've also been told that languages other than C# can be used with .net - is that true? if so which other languages and how does this work.
If I've sent this to the wrong forum then please let me know where to go
Thanks very much
Tim Huffam
|
|
|
|
|
There is mono:: (www.go-mono.org) which is a free implementation of .NET that does run on Linux. It's no where near complete. The web services are coming along, but they are just at the beginning of starting Windows.Forms implementation (I think one group is using a native Win32 work-alike layer called Wine (www.winehq.com) to implement it). Anyway, take a look at the web page and class status to get an idea of where they are and what's left to do. You can even help out!
Visual Basic.NET, Visual C++.NET, C#, and some other languages (I think they have Eiffel running now) all can use the .NET framework.
|
|
|
|
|
Thanks very much Anon
I'm still unclear as to what exactly .Net provides/does - eg if I have a thin client VB app what could I run it on VB.NET and if so what would it do different to the original app?
Thanks again
Tim
Tim Huffam
|
|
|
|
|
|
I have a fully functional ASP.NET set of pages but now want one of the pages to retrieve and parse/process another page. I construct an URL similiar to:
http://site.com/GetDetails.asp?Account=12345
and use the WebRequest class to go fetch the page, however, it doesn't work. It worked when the URL was just a straight forward .HTML page, but not as an ASP with parameters. The error returned is:
The underlying connection was closed: The remote name could not be resolved.
Maybe I'm using the wrong class. Any help gratefully received.
|
|
|
|
|
Have researched/tested/debugged this a bit more. I'm convinced I'm using the right classes, and correctly. What I believe is happening is that whilst I can access the URL through a browser, it is in fact going thru a Proxy server although I don't know the details of the Proxy server. So, in my original text I probably over simplified the example URL and something like:
http://makearequest.site.com/GetDetails.asp?Account=12345
is more like it. I can ping site.com , but i can't ping makearequest.site.com
I'm desperate to get this working... any other classes that would work round the whole proxy thing?
|
|
|
|