Page 36 of 39

Posted: Sat Mar 21, 2009 12:35 pm
by srod
The system menu has been deactivated here.

Are you saying that Excel's system menu still works?

The normal Excel menu should work okay - just the system one which I have deactivated.

Posted: Sat Mar 21, 2009 12:38 pm
by ts-soft
> Are you saying that Excel's system menu still works?
There is no normal systemmenu, but the menu (the ugly round thing) works.
You can close, open and so on!

Posted: Sat Mar 21, 2009 12:44 pm
by srod
Ahhh, never used Office 2007!!! Any idea how to disable that thing?

Posted: Sat Mar 21, 2009 12:59 pm
by ts-soft
No idea :?

Privat, i use only openoffice, looks better :D

Posted: Sat Mar 21, 2009 2:47 pm
by CNESM
**EDIT : problem with the above code. Select a cell, move the window off screen and back again and then try to select other cells!!! Having trouble fixing this. If anyone can find a fix then that would be very useful! I'll keep searching...
The same effect with Office 2000 but only when one excel instance in the task manager still run. Close all hitten instance and try it again, then it works fine with office 2000 (i know, office 2000 is old, but old skool doesnt lose his positive charisma :-D)

http://mitglied.lycos.de/cnesm/e.GIF

Long way around to come to finish line, but this example is great. You are the best, scrod! :)

New Point 1.

Yesterday, i found some new interesting thing (maybe clother to the thing we had already see):

If you set the "SetEventHandler" to the Excel.application you can catch all internal excel events. For example:
NewWorkbook
WorkbookActivate
WindowActivate
WorkbookBeforeClose
WindowDeactivate
WorkbookDeactivate
...
Simple example:

Code: Select all

Procedure myEventCallback5(object.COMateObject, eventName.s, parameterCount)
Debug eventName
EndProcedure

objExcel=COMate_CreateObject("Excel.Application")
HRESULT=objExcel\SetEventHandler(#COMate_CatchAllEvents,@myEventCallback5()) 
Thats great! So you can better see, what excel does!

New Point 2.

Maybe i am little stupid but does COMate support threads? This simple thread example didn't work althrough the objExcel is still avaible in the thread procedure:

Code: Select all

XIncludeFile "C:\Desktop\COMate_Residents.pbi" 
XIncludeFile "C:\Desktop\COMate.pbi" 

Global objExcel.COMateObject

Procedure DeineProzedur(a)
  objExcel\SetProperty("Cells(2,1) = 'But this input is NOT successfull!'")
EndProcedure
 
objExcel=COMate_CreateObject("Excel.Application")
objExcel\SetProperty("Visible = #True")
objExcel\GetObjectProperty("Workbooks\Add")

objExcel\SetProperty("Cells(1,1) = 'This input is successfull!'")

thread=CreateThread(@DeineProzedur(),0)

MessageRequester("Information", "", #PB_MessageRequester_Ok)

objExcel\SetProperty("DisplayAlerts = #False")
objExcel\Invoke("Workbooks.Close")
objExcel\Invoke("Quit")
But a simple procedure works fine:

Code: Select all

XIncludeFile "C:\Desktop\COMate_Residents.pbi" 
XIncludeFile "C:\Desktop\COMate.pbi" 

Global objExcel.COMateObject

Procedure DeineProzedur(a)
  objExcel\SetProperty("Cells(2,1) = 'And with a simple procedure this input is successfull, too!'")
EndProcedure
 
objExcel=COMate_CreateObject("Excel.Application")
objExcel\SetProperty("Visible = #True")
objExcel\GetObjectProperty("Workbooks\Add")

objExcel\SetProperty("Cells(1,1) = 'This input is successfull!'")

DeineProzedur(1)

MessageRequester("Information", "", #PB_MessageRequester_Ok)


objExcel\SetProperty("DisplayAlerts = #False")
objExcel\Invoke("Workbooks.Close")
objExcel\Invoke("Quit")
Maybe i am too stupid to do that right :?

Posted: Sat Mar 21, 2009 5:07 pm
by Kwai chang caine
CNESM wrote:
**EDIT : problem with the above code. Select a cell, move the window off screen and back again and then try to select other cells!!! Having trouble fixing this. If anyone can find a fix then that would be very useful! I'll keep searching...
The same effect with Office 2000 but only when one excel instance in the task manager still run. Close all hitten instance and try it again, then it works fine with office 2000 (i know, office 2000 is old, but old skool doesnt lose his positive charisma :-D)
?
+ 1 8)

For info, that's work fine, even if there are another instance of EXCEL 2000, XP PRO SP2 8)
OFFICE 2000 it's like XP PRO, perhaps a little old, but better, efficient and not a christmas tree like VISTA and OFFICE 2007 :?

Posted: Sat Mar 21, 2009 6:20 pm
by CNESM
For info, that's work fine, even if there are another instance of EXCEL 2000, XP PRO SP2
OFFICE 2000 it's like XP PRO, perhaps a little old, but better, efficient and not a christmas tree like VISTA and OFFICE 2007
Yes, you say it. Vista is like big shining blink blink, but no diamont, more likey a cheap plastic stone :wink:

I don't talk from a normal running excel instance further from a iregular hidden running application thats only display in the task manager.

Posted: Sat Mar 21, 2009 9:16 pm
by srod
New Point 2.

Maybe i am little stupid but does COMate support threads? This simple thread example didn't work althrough the objExcel is still avaible in the thread procedure:
This took some sorting out this did!!! :)

First thing you have to initialise COM on each thread.

Second, and more importantly, COMate uses a single threaded apartment model (which is not good for multi-threaded access to a single object instance!) I can get your code working when I adjust COMate to use a multi-threaded apartment model, but this causes problems for PB itself. See the following reply from Freak regarding this : http://www.purebasic.fr/english/viewtopic.php?t=36830

The point is that I cannot persist with this adjustment to COMate because of what it means for PB and so we must look elsewhere for a solution.

Basically, with the single-threaded apartment model, a thread cannot directly call methods on an object it did not create. The way around this is to bully COM into serialising such method calls and for us to 'marshall' our object pointers for use by different threads. Now COM handles the serialising (via a hidden window's message queue), we must handle the marshalling aspect through a couple of api function calls. Functions which don't fit that well into the COMate way of doing things I'm afraid!

To be honest, I am not 100% sure if I want to add this cross-thread marshalling to COMate? It appears simple enough, but how many people would require this as a serious addition to COMate?

Posted: Sun Mar 22, 2009 4:19 pm
by CNESM
Hi srod,

thanks that you take care about this point! The advantage must stay in reconcile to the expenditure of this problem. It doesn't make sense to change a function or add a new feature only to add a new feature, when you know what i mean :-). When this changes bring additionaly more trouble to PB then it will be better when you doesn't change the STA to MTA. Maybe its useful when you add this information to the help file of COMate, so the next user will not ask when he have the same stupid knowledge like me ;-D

I will handle this point by another way! Thanks scrod!

Posted: Sun Mar 22, 2009 10:05 pm
by srod
Well, as I say, changing to MTA is not possible because of the information imparted by Freak. What is possible is the marshalling of interface pointers between the different threads, but I will add this only if there is a real need. :)

Posted: Tue Mar 24, 2009 11:17 am
by CNESM
This function would not be bad, i think, but no stress, scrod, with this ne function. Maybe the other users see it in a other way ...

Posted: Tue Mar 31, 2009 11:29 am
by SFSxOI
If I have this:

Code: Select all

objPorts = colPorts\GetObjectProperty("Item(" + Str(I) + ", " + Str(#NET_FW_IP_PROTOCOL_TCP) + ")")

(which doesn't work by the way)

This is the original function
C++

HRESULT Item(
  [in]   LONG portNumber,
  [in]   NET_FW_IP_PROTOCOL ipProtocol,
  [out]  INetFwOpenPort ** openPort
);

VBScript
Function Item( _
  ByVal  port, _
  ByVal ipProtocol _
)

Is there a better way to use this without the strings and just put the values in as val and not strings?

Posted: Tue Mar 31, 2009 11:56 am
by srod
Only by using variants directly, but then that is even more long winded.

If it doesn't work then I would guess that there is something wrong with your code. What error does COMate report?

Posted: Tue Mar 31, 2009 1:09 pm
by SFSxOI
Its that method is not correct thing. I was concerned about adding that second parameter and its a correct parameter but I'm not sure if i added it correctly but i think i did. I may not be doing it correctly tho because i don't know if i have to build a collection first but it doesn't seem like i should need to. I just started on it this morning early about 4 AM so maybe its as simple as not enough coffee yet :)

Posted: Tue Mar 31, 2009 1:11 pm
by srod
You mean "One or more arguments are invalid...." ?