|
|
|
|
I have created an AppBar. The AppBar always stays on top, when it loses focus, then to get back to the AppBar requires two clicks instead of one. I believe the first click activates the form and then with second click I receive the mouse click events (as expected). Can you give any ideas, what can be wrong here? My problem is similar to this one Appbar and focus issues[^]. Unfortunately the OP in that link hasn't posted his solution
I created the AppBar following this article from CodeProject C# does Shell, Part 3[^]
I looked into it with Spy++ but don't have any idea why this is happening.
Here is the Spy++ log which I obtained testing out this scenario (first click doesn't works, second does).
<00001> 00090CFE S WM_PARENTNOTIFY fwEvent:WM_LBUTTONDOWN xPos:25 yPos:17
<00002> 00090CFE R WM_PARENTNOTIFY
<00003> 00090CFE S WM_WINDOWPOSCHANGING lpwp:0418EAE4
<00004> 00090CFE R WM_WINDOWPOSCHANGING
<00005> 00090CFE S WM_ACTIVATEAPP fActive:True dwThreadID:00000000
<00006> 00090CFE R WM_ACTIVATEAPP
<00007> 00090CFE S WM_NCACTIVATE fActive:True
<00008> 00090CFE R WM_NCACTIVATE
<00009> 00090CFE S WM_ACTIVATE fActive:WA_CLICKACTIVE fMinimized:False hwndPrevious:(null)
<00010> 00090CFE S WM_IME_SETCONTEXT fSet:1 iShow:C000000F
<00011> 00090CFE S WM_IME_NOTIFY dwCommand:IMN_OPENSTATUSWINDOW dwCommand:00000002 dwData:00000000
<00012> 00090CFE R WM_IME_NOTIFY
<00013> 00090CFE R WM_IME_SETCONTEXT
<00014> 00090CFE S WM_SETFOCUS hwndLoseFocus:(null)
<00015> 00090CFE R WM_SETFOCUS
<00016> 00090CFE R WM_ACTIVATE
Now happens the second click (which works)
<00017> 00090CFE S WM_PARENTNOTIFY fwEvent:WM_LBUTTONDOWN xPos:25 yPos:17
<00018> 00090CFE R WM_PARENTNOTIFY
<00019> 00090CFE S WM_WINDOWPOSCHANGING lpwp:0418E40C
<00020> 00090CFE R WM_WINDOWPOSCHANGING
Looking at the Spy++ logs, I believe the problem is with activation, I think that it only receives WM_LBUTTONDOWN event if the window is activated. But how come other windows aren't activated but they still work with one click (i.e. I don't have to click it first).
EDIT:I think the problem is with the ToolStrip. I have a ToolStrip in my AppBar. Now how I verified this? Well on the same form I created a button and showed a message box in its click event and it is working fine. Now how to remedy that?
modified on Thursday, June 24, 2010 1:12 PM
|
|
|
|
|
Hello there,
i want to add buttons to tool tip in .net but i think it is not that straight forward. may be because its parent is not control i cant add them. any suggestions will be appreciated
best regards
|
|
|
|
|
mobasher wrote: any suggestions will be appreciated
On mouse move, display a form with a button in it?
|
|
|
|
|
Look at this article: Custom Mouse Cursors (VB.NET)[^] specifically the PopCursor
It uses a ToolStripDropDown to create a custom tooltip. It would be possible to add buttons to that and that would be the approach that I would take. You could use a new form, but that's a little over-kill.
|
|
|
|
|
Hello Friends
I am having one jar file And now I want to call some java methods from c# code.Is there any way to call ?
Any Help will be Appreciated.
Thanks & Regards
Yogesh
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:16am.
|
|
|
|
|
Hello Qwertz
I tried with Ikvmc compiler that I got thru ur link.Its creating a dll and I added as refernce to c# project.I am able to get all the functions there in c# project too but when I run then it gives error of java.lang.NoclassFoundError.
Any Other Ideas?
Regards
Yogesh
|
|
|
|
|
I am not sure if you can do this directly. C# runs in the .NET environment while Java programs run in the Java VM and there is no direct link between them that I am aware of. You can call C/C++ libraries from Java and vice versa but that is using the native code interface.
It's time for a new signature.
|
|
|
|
|
Thanks Qwertz for this link and Mr Richard I think the link that Qwertz provided me is useful to link java jar with c#.
Now the Prob is that with Ikvmc compiler i converted the jar files into Microsoft Compatibility Enviorenment Dll and adding them as refernce to c# project.
but now the prob is that compiler only converting java class to tht dll not java3d libraries and my jar file contains java3d lib also.
So,Any other Ideas?
Thanks & Regards
Yogesh
|
|
|
|
|
I have created a collection class which has below methods
Class EmPInfo
{
Count()
Add (Struct classinfo)
Item()
Sort()
}
This class uses List<> object ,which holdes Emp class obj.
Add method internally craetes a EMP class object and stores that data in a list object.
Sort function perform sorting using some information set by the user.
Please suggest the correct way of creating a colletion class in .Net.
|
|
|
|
|
I'm confused - you already have your answer (you gave it yourself) but you're still asking how to do it?
|
|
|
|
|
Implement ICollection<T> and wrap your list or derive from List<T>
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:16am.
|
|
|
|
|
Since v2.0 this is not the recommended way due to the boxing/unboxing expense (an ArrayList which holds object s is used for the InnerList ). Instead you should use System.Collections.ObjectModel.Collection<T>[^].
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Good day all.
This is the first time I ask a question here, but have been using codeproject for some time now. Great site - Good work!
Im doing a C# windows forms application that reads data from Windows Sql Server Express and then displays the data from a specific table in a datagridview (im using bindingsource). This is no problem. The problem is my table is quite large more than a thousand rows. Currently all the data displays at one time with vertical scroll bars to scroll down. But I would like to only display a fixed number of rows, say the last 10 entries.
Is this at all possible.
Hope this question has not been asked before. Searched through a bunch of forums and websites and could not get the right question with an answer.
Thanks in advance.
Cobus
|
|
|
|
|
Sorry to answer my own question, but I found a solution:
Instead of using the datagridview to show only the newest 10 entries I changed my SQL Query which will fill my datatable to:
SELECT TOP 10 Column1,Column2
FROM Table_Name
ORDER BY Column1 DESC
This result is then the 10 most recent entries in the table. Without the DESC keyword the first 10 entries will be displayed
Thank you in any case.
|
|
|
|
|
Cobusvdvyver wrote: Sorry to answer my own question, but I found a solution:
Its never a bad thing to answer your own question, it shows you are working and not just waiting for the codz to be sent to you. Also feedback on the solution may help another and stops those who help from spending resources on an answered question.
So have 5 and keep it up.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have just written my first C# application that has been released to the wild, so be gentle with me!
The application runs as part of a logon script for all users in a domain to force them to accept network terms and conditions. If they have not previously accepted, a screen is displayed containing a webbrowser control which displays a html file containing the t&c's - the user accepts and a value is stored in the AD and the use is not asked again next time. The t&c's are too large to be displayed in full in the webbrowser without scrolling.
This all works fine, but the customer has asked that the accept/decline buttons are not enabled until the user has scrolled to the end of the HTML document, so the are forced to see (though we can't guarantee that they read) the complete document.
Is there any way of detecting that the user has scrolled to the end of the document? Is any event fired, or is there some other way I can do this?
====================================
Transvestites - Roberts in Disguise!
====================================
|
|
|
|
|
This is relatively painless to do, but requires a little bit of work. What you need to do is place your text inside a div control which will serve as the scroll container - note, make sure that your web browser doesn't have nav bars enabled - this can be a bit confusing. Now, set your div to look like this
<div id="containerDiv" wrap="soft" style="border-style:window-inset; overflow-x:visible; overflow-y:scroll; height="100%"><!-- add your contents here --></div> You need to reference the MsHtml com library and hook that up so that you can get access to the div element. Now, I added a simple UserControl which inherits from the webbrowser, and uses a timer to check the whether or not the scroll height indicates that the end of the page has been reached. Here's the user control:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using mshtml;
namespace LicenseScreen
{
public partial class LicenseControl : WebBrowser
{
private bool _endReached;
private HTMLDivElement _div;
private Timer _timer;
public EventHandler LicenseScrolledToEnd;
public LicenseControl()
{
InitializeComponent();
ScrollBarsEnabled = false;
this.Navigate("about:blank");
}
public void LoadContent(string content, string containerDiv)
{
Document.Write(content);
_div = this.Document.All[containerDiv].DomElement as HTMLDivElement;
EndReached = _div.scrollHeight <= this.Height;
_timer = new Timer();
_timer.Interval = 200;
_timer.Tick += new EventHandler(_timer_Tick);
_timer.Start();
}
void _timer_Tick(object sender, EventArgs e)
{
if (_endReached)
_timer.Stop();
TestLocation();
}
private void TestLocation()
{
EndReached = _div.scrollHeight == (_div.scrollTop + _div.clientHeight) ||
_div.scrollHeight <= this.Height;
}
public bool EndReached
{
set
{
_endReached = value;
if (value)
{
EventHandler handler = LicenseScrolledToEnd;
if (handler != null)
handler(this, EventArgs.Empty);
}
}
}
}
} And here's an example of the code that calls into it:
public partial class LicenseForm : Form
{
public LicenseForm()
{
InitializeComponent();
}
private string BuildPage()
{
StringBuilder sb = new StringBuilder();
sb.Append("<html><head><title>My License</title></head>");
sb.Append("<body>");
sb.Append("<div id='containerDiv' wrap='soft' ");
sb.Append(" style=\"border-style:window-inset; overflow-x:visible; overflow-y:scroll; height='100%'\">");
for (int i = 0; i < 300; i++)
{
sb.AppendFormat("<p>This line represents line {0} in my license</p>", i);
}
sb.Append("</div></body></html>");
return sb.ToString();
}
private void LicenseForm_Load(object sender, EventArgs e)
{
licenseControl.LicenseScrolledToEnd += new EventHandler(licenseControl_PropertyChanged);
licenseControl.LoadContent(BuildPage(), "containerDiv");
}
void licenseControl_PropertyChanged(object sender, EventArgs e)
{
btnAccept.Enabled = btnCancel.Enabled = true;
}
}
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I have finally got it working in a demo project (not your fault - I'm just slow!)
Many thanks
Chris
====================================
Transvestites - Roberts in Disguise!
====================================
|
|
|
|
|
I had one problem with it - when I tried to use my html file, everytime it checked its scroll position, it was detecting that it was at the end of the file and activated the button, but the scrollbar was disabled. I finally tracked it down to a DOCTYPE directive in the first line of the file. When I removed this, it worked perfectly.
The line causing the problem was:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
====================================
Transvestites - Roberts in Disguise!
====================================
|
|
|
|
|
Further research shows that the problem occurs whenever there is a on the fly as well, as the html is provided and maintained by the client, so I can't be sure that someone is not going to screw up the file and remove the DIV
====================================
Transvestites - Roberts in Disguise!
====================================
|
|
|
|