|
first of all thanks for your answer...
but sorry,no,it's not what i want.i knew ExitWindows or ExitWindowsEx API function,but i didn't and still don't want to actually logoff the computer,i just want to show the coloured dialog box Windows Xp shows to the user when s/he clicks on the Logoff button on the start menu taskbar.
I hope to make it clearer in this example:ExitWindows also shuts the computer down.So,if i had wanted to do so,i would have used the above-mentioned function:but to show the shutdown dialog box i would instead have used the SHShutdownDialog function(try it in the example i have written below).So,i was searching for a similar api,or whatsoever goals the same result with the logoff dialog box.
example in vb6:
<br />
Private Declare Function SHShutDownDialog Lib "shell32" Alias "#60" (ByVal YourGuess As Long) As Long<br />
Private Sub Form_Load()<br />
'KPD-Team 1999<br />
'URL: http:
'E-Mail: KPDTeam@Allapi.net<br />
SHShutDownDialog 0<br />
End Sub<br />
-- modified at 4:54 Tuesday 9th May, 2006
|
|
|
|
|
i have finally found this completely-undocumented API function:
Public Declare Function SHLogoffDialog Lib "shell32.dll" Alias "#54" (ByVal hWnd As Integer) As Integer
(of course the integer type is intended for .net,otherwise you should use the long one)
well done!
byeeeeeeee
|
|
|
|
|
Apologies for sending you incorrect data. I mis-understood your requirements. Sorry about that.
Undocumented - many are and Microsoft should consider publishing them and I hear the reasons for not using these as they are unsupported and Microsoft are at liberty to change/remove without regard - I have seen many postings about using undocumented code.
modified 1-Aug-19 21:02pm.
|
|
|
|
|
abbottra don't worry!no problem..
in fact.but they're so useful functions....anyway i didn't know they're free to change them...even if i use them only for a home application,i will bear in mind.
thanks again
|
|
|
|
|
I have a textbox having text in "dd/MM/yyyy" format (eg. 16/05/2006)
How i assing this text to a Date Object?
I am using Date object = format(textbox1.text, "dd/MM/yyyy")
this cause error
|
|
|
|
|
What kind of error? Just saying 'this cause error' does not really help.
PC
|
|
|
|
|
The Format method is used to create a string, not parse it.
Use the DateTime.ParseExact method.
---
b { font-weight: normal; }
|
|
|
|
|
how can i use microsoft flexgrid in vb.net
|
|
|
|
|
|
Hi there,
I have a question concerning the datagridview in vb.net 2005.
Is it possible to change the text-alignment of a certain column in the datagridview? If so, how do I do this?
Thanks!!!
G72360
|
|
|
|
|
|
I have written a program to View a Specific webpage with an option to refresh this site.
Picture of Program Layout
Is there any possible way to Extract the Number Online( ? out of 12 ) to an integer into the program? The page is written in php and is not my own. The variable I am trying to get is under the "Online" Column{1,12 Cell} in Row 2{2,12 Cell}.
Purpose being..
If Online > 1 Then
Scream bloody murder
End If
This program has NotifyIcon incorporated, so having this hidden and still checking for players would be the ideal goal.
Thank you in advance for any and all help. I appreciate your time in helping me with this matter.
TehCheeze
-- modified at 6:56 Sunday 7th May, 2006
P.S. -- The html for the WebSite is as follows
<br />
<table width="100%" border=1><br />
<tr><br />
<th>Name</th><br />
<th>Dedicated</th><br />
<th>Password</th><br />
<th>CMaps</th><br />
<th>Time online</th><br />
<th>Map</th><br />
<th>Game Type</th><br />
<th>Teams</th><br />
<br />
<th>Respawn</th><br />
<th>Lives</th><br />
<th>Target</th><br />
<th>Online</th><br />
</tr><br />
<tr><br />
<td><a href="cm://86.137.187.125:41230">Saturn</a></td><br />
<td>Yes</td><br />
<td>No</td><br />
<td>No</td><br />
<br />
<td>61135</td><br />
<td>Temple Dar</td><br />
<td>CTF</td><br />
<td>Yes</td><br />
<td>Normal</td><br />
<td>0</td><br />
<td>100</td><br />
<td>0 / 12</td><br />
</tr><br />
<br />
</table><br />
<p>Note: Temporary page, list function only not worked on layout/visual design yet.</p><br />
<br />
|
|
|
|
|
I have done some "data scraping" myself in the past extracting data from website pages. The problem you will run up against is when the positioning of the data youre interested in moves, especially of the person who owns the site changes their page. These days pages that are being generated use scripts to build up the page dynamically and this means that in order to extract your information with as little maintenance as possible, you will need to parse the page and present the data in a format which your own code can understand.
My own code which was developed in vbScript parsed the page looking for various tags such as href's titles meta data etc and the function (shown below) worked reasonably well, so you should be able to convert this into your VB application quite easily.
When scraping a page of unknown content, you have to be aware of pitfalls such as the tag you are looking for being embedded inside javascript as the autor may well write something like document.write("<tr><td class='myClass'>Saturn</td>.....");
Which really excaberates the problem. Trying to write a parser which covers all eventualities is extrememly hard. HTML 1.0 is one thing, but now with XHTML and XML the problem just grows. This is why browsers are always continuously being updated.
Having said that the function below might be spawn off some thoughts. It was called from a loop which keeps calling the GetTag and passing the updated pointer into the page back again. Not also that the Get Function can be recursive if a certain condition arises. You would probably need to do a similar thing when looking for a table tag as table can be embedded inside tables and of course a table has many rows and columns.
This is not an easy answer to your problem. There is most probably an easier way so simply locate the table tag and then count the number of columns you have located and simply extract the data inside the column for your program. But for maintenance free code which caters for the page authors making changes, then the parser method will have much more lengevity and can always be re-used in other projects.
Remember that this code is a little dirty and was used as a concept prover. But I hope it helps you with your problem. (Trying to get the formatting right in this post is a real pain when its a mixture of tabs and spaces!)
<pre>
call GetHTMLPage(strTemp) ' Grab the page into strHTML
iPos = 1
do while (iPos > 0)
iPos = GetTag ("href", strHTML, iPos, nNode, true)
loop
</pre>
<pre>
Function GetTag(strTag, str, iStartPos, thisNode, bStandardTag)
Dim i, pos, iStartScriptPos, iEndScriptPos
if objProps.DebugInfo then Response.Write "GetTag : " & strTag & "," & iStartPos & "<br>"
' Look for the tag in the stream
pos = Instr(iStartPos,str, strTag, vbTextCompare)
if bStandardTag then
pos = Instr(iStartPos,str, "<" & strTag & ">", vbTextCompare)
else
pos = Instr(iStartPos,str, strTag, vbTextCompare)
end if
' Check to see if one has been found
if pos >= iStartPos then
' Walk backwards to discover if we are inside a <script> tag
for i = pos to 1 step - 8 ' 8 is the length of '<script>'
iStartScriptPos = Instr(i, str, "<script" , vbTextCompare)
' Check to see if we were inside a script
if iStartScriptPos > 0 and iStartScriptPos < pos then
if objProps.DebugInfo then Response.Write "<span style=""color:green""><script>" & iStartScriptPos & "</span><br>"
exit for ' If we were then we need to examine closer so exit now
end if ' Otherwise
next ' keep looking backwards
' Check to see if we did actually find a '<script>' and if so look for the corresponding '</script>'
' This assumes that the page actually has a terminating tag
if iStartScriptPos > 0 then
iEndScriptPos = Instr(iStartScriptPos, str,"</script>", vbTextCompare)
end if
' Now that we have some positions of both the '<script>' and '</script>
' we can cehck to see if our tag was actually inside them
' If so then we can set the bInScript Flag
if ( iEndScriptPos > iStartScriptPos) and _
( iStartScriptPos > 0 ) and _
( pos < iEndScriptPos) and _
( pos >= iStartScriptPos) then
' We need to ignore anything in JS Comment Lines
if objProps.DebugInfo then
Response.Write "<span style=""color:blue"">" & _
objUtils.HTMLEnc(mid( str, iStartScriptPos, (iEndScriptPos-iStartScriptPos + len("</script>")) )) & _
"</span><br>"
end if
Dim arrScript, iComment, idx, strC, iLen, iResult, iTag
' We are inside <script> ... </script> and hrefs could be inside comments such as // so
' we need to check. Best way so far is to split the scetion into an array of lines
' and keep looking
arrScript = split( mid(str,iStartScriptPos,iEndScriptPos - iStartScriptPos), vbNewLine )
for idx = 0 to UBound(arrScript)
strC = arrScript(idx) ' Place line onto temp buffer
iLen = len(strC) ' cache the length
iComment = Instr(strC,"//") ' Start of comment
if iComment <= 0 then iComment = iLen
iTag = Instr(strC, strTag, vbTextCompare) ' Start of tag on this line
iResult = 1
'Response.Write "Line(" & idx & ") " & strTag & "-" & iTag & " " & objUtils.HTMLEnc(strC) & "<br>"
' Recurse along this line looking for tags
do while (iTag > 0 and iTag < iComment and iResult >0)
iResult = GetTag(strTag, strC, iResult, thisNode, bStandardTag)
loop
next ' So onto the next line
pos = iEndScriptPos
else
' We have located a tag so start getting some stuff
' walk backwards and locate the start of tag e.g. '<'
' but as in bbc.co.uk there is 'news_console_link.href= ... so check for a period also
if not bStandardTag then
Dim iSanityCheck : iSanityCheck = pos
do while mid(str,pos,1) <> "<" and pos > 1
'Response.Write "Scanning backwards: ( " & pos & ") " & mid(str,pos,1) & "<br>"
pos = pos -1
loop
pos = pos + 1 ' We dont want to include the '<' though
' build up a string with the tag details
Dim strTemp : strTemp = ""
do while (mid(str,pos,1) <> ">" and pos < len(str))
'Response.Write "Scanning: forwards: ( " & pos & ") " & mid(str,pos,1) & "<br>"
strTemp = strTemp & mid(str, pos, 1)
pos = pos + 1
loop
pos = pos + 1
if pos < iSanityCheck then
pos = iSanityCheck + len(strTag)
if objProps.DebugInfo then Response.Write "<span style=""color:red"">Exit GetTag SanityCheck : </span> " & pos & "<br>"
GetTag = pos
Exit Function
end if
else
' Simply look for the closing tag as eveyrthing else inside is all thats called for
strTemp = ""
pos = pos + len(strTag) + 2
do while (mid(str,pos,1) <> "<" and pos <= len(str))
strTemp = strTemp & mid(str, pos, 1)
pos = pos + 1
loop
do while (mid(str,pos,1) <> ">" and pos <= len(str))
pos = pos + 1
loop
pos = pos + 1
end if
' We now have a temporary string with the required tag data
' So we now need to either add this tag into the child list if its an href
' or simply stuff the information into this nodes information
call ApplyInfo(strTag, strTemp, thisNode)
'pos = pos + len(strTemp)
end if
end if
if objProps.DebugInfo then Response.Write "<span style=""color:green"">Exit GetTag returns: </span> " & pos & "<br>"
GetTag = pos
End Function
</pre>
|
|
|
|
|
Hi all,
i have SQL script that i will execute it in class and i have to add this SQL file to the class ,but i need no one else see this file ,so i make the copy option to be"Do not copy" , but i use this file to read from it ,so when i use the created dll in another solution , it can't find that file
what exactly shall i do?
your answers will be appreciated
Thank you
|
|
|
|
|
I think your SQL file is inside the Project so when you use the dll in the project . you find it but when you try to use the same DLL from another project it does not give you path. So two solutions.
1. encrypt the file and let it be with copy on the system. and decrypt it when required.
2. make a function in the class and it will hold the query in string array and will return it back to you when you call it or directly run it when you pass some required parameters.
Rizwan Bashir
|
|
|
|
|
thank you Rizwan ,
can u guide me how to do the encryption? so that when file exist in the customer's machine can't be opened!!!
|
|
|
|
|
|
Hi all
suppose I have these lines:
AddHandler MyControl1.Parent.Paint, AddressOf PaintParentHandler1
AddHandler MyControl2.Parent.Paint, AddressOf PaintParentHandler1
AddHandler MyControl3.Parent.Paint, AddressOf PaintParentHandler1
AddHandler MyControl1.Parent.Paint, AddressOf PaintParentHandler2
AddHandler MyControl1.Parent.Paint, AddressOf PaintParentHandler3
The questions are:
- how can I find, at runtime, the procedures that are attached to a given event?
- how can I find, at runtime, the events a given procedure is subscribed to?
In other words: what are the procedures that reacts to MyControl1.Parent.Paint and to which events PaintParentHandler1 respond?
Thanks a lot
-- modified at 3:19 Sunday 7th May, 2006
|
|
|
|
|
Hi,
1. if the event is within the same class than a call to GetInvocationList will give you an array of Delegates. I think the compiler will not accept this when calling it on an event defined outside the current class. You might nevertheless reach it via Reflection.
2. Not possible. An event is simply a collection of references to methods and the referenced methods don't know anything about it.
|
|
|
|
|
Hi Robert,
1. if the event is within the same class than a call to
GetInvocationList will give you an array of Delegates.
I think the compiler will not accept this when calling it on an
event defined outside the current class. You might nevertheless
reach it via Reflection.
Absolutely right! I've found a lot of samples that uses MyEventEvent.GetInvocationList(). Unfortunately for me, they are all inspecting events INSIDE the same class where they are declared. In my case, I need to find a list of eventhandlers for an event of a given object used elsewhere. The MyControl1.Parent.Paint sample is not casual...
Do you have an idea on how solve it using Reflection?
2. Not possible. An event is simply a collection of references
to methods and the referenced methods don't know anything about
it.
I agree. But what I'm thinking is that the compiler exactly knows that a procedure is attached to an event.
However, for me is much more important to solve #1.
As you can see in the first three lines of my sample, lines 2 and 3 are useless. In fact, if MyControl1, MyContro2 and MyContro3 are inside the SAME parent, PaintParentHandler1 is called three times, while only the first time is needed.
Thank you for any suggestion...
carlo
-- modified at 4:07 Sunday 7th May, 2006
|
|
|
|
|
Hi,
I've played around a bit but just couldn't bring the compiler to accept any call (even reflection) on an event. I know it must be somehow possible (because some tools I've seen are able to do so) but I don't know how they made it.
The only other workaround for your problem I can image would be holding a seperate list which holds the already bound references which you could check before binding the next event.
|
|
|
|
|
Hello Robert
you are right. Mantaining an embedded list of eventhandlers calls is a good idea.
However, yesterday I implemented and tested this:
<br />
RemoveHandler MyControl1.Parent.Paint, AddressOf PaintParentHandler1<br />
AddHandler MyControl1.Parent.Paint, AddressOf PaintParentHandler1<br />
<br />
RemoveHandler MyControl2.Parent.Paint, AddressOf PaintParentHandler1<br />
AddHandler MyControl2.Parent.Paint, AddressOf PaintParentHandler1<br />
<br />
RemoveHandler MyControl3.Parent.Paint, AddressOf PaintParentHandler1<br />
AddHandler MyControl3.Parent.Paint, AddressOf PaintParentHandler1<br />
This allows to have just a single PaintParentHandler1 call whithout any useless stack... and seems to work!
Thank you for your help.
Carlo
-- modified at 3:15 Monday 8th May, 2006
|
|
|
|
|
Hi all,
I have a Winforms 2.0 app in which I have a DataGridView which is populated from my own data objects (ie: from my own classes, not from a database or strongly typed dataset). The DGV is readonly so no editing or adding new rows can be done. Since some of the columns need to have a custom sort I set the SortMode property on those columns to "Programmatic" and then added the following event handler to the code:
Private Sub dgvMeetings_SortCompare(ByVal sender As System.Object, ByVal e As DataGridViewSortCompareEventArgs) Handles dgvMeetings.SortCompare
'Try to sort based on the columns in the current column.
e.SortResult = System.String.Compare(e.CellValue1.ToString(), e.CellValue2.ToString())
'If the cells are equal, sort based on the race start time column
If e.SortResult = 0 Then
e.SortResult = System.String.Compare(dgvMeetings.Rows(e.RowIndex1).Cells("RaceDate").Value.ToString(), _ dgvMeetings.Rows(e.RowIndex2).Cells("RaceDate").Value.ToString())
End If
e.Handled = True
End Sub
However, this event is simply not firing at all... I can click on the column headers until I'm blue in the face and the event never fires. The columns in the DGV that are set to sort automatically work fine so would anyone know why SortCompare is not working? I also tried adding an AddHandler which pointed to the same method (without the "Handles ..." of course) and it still ignores it. I actually got the code above from the MS document about the DGV (at http://download.microsoft.com/download/5/6/4/5646742C-3EB7-48F7-BFB3-CC295D618CF9/DataGridView%20FAQ.doc) in which it says this is the way to custom sort unbound data - but it doesn't seem to work for me... anyone know what I might be missing here?
TIA for any help...
Mike
-- modified at 0:13 Sunday 7th May, 2006
|
|
|
|
|
Worked out what is was - I actually needed to set the sort mode of each column to "Automatic" rather than "Programmatic". Seems the latter mode is really only for managing the sort glyphs etc. Now the SortCompare event fires but I have a new problem which is to get numeric columns such as "Race Number" to sort by the value (not the string value) then by the race start date (which is a DateTime column).
I was going to delete this post but thought I'd leave it there for anyone else that runs into the same problem.
Mike
|
|
|
|
|
hi all
i want to insert the value in field of type "time stamp" in sql server 2000 from vb.net application. that field is not null.
when i had tried to insert new record in a row of table leaving time stamp field empty but it insert value as <binary>. how to get time stamp and insert into sql server.
Tasleem Arif
|
|
|
|
|