How can I place a button on the title bar? - vb.net

I am attempting to make a button that shows a user-menu, as seen in Google Chrome:
There's no legacy way of doing this, so I've had a look around and I have found that every way of doing this is either outdated or does not work (probably because it's outdated!).
This is the first link I found, but however it only works with Windows Aero off, and probably not with Windows 8, 8.1, or 10, and not very well. The answer to this Stack Overflow question is also essentially the same code:
Aero on:
I have also found some questions here, but the techniques mentioned do not work. One of the answers points to this MSDN article which appears to offer some of the functionality I want, but the code however is c++.
Is this possible in VB.NET without any issues, and if so, how?
This is with VB.NET and Windows Forms, target operating systems are Windows 7 and newer.

Take a look at these 2 links:
Adding caption buttons to the Non-client area on Vista
.Net ActiveButtons Library
It's been a while since I've used VB.Net, so if you don't mind I'll just add a c# code example (basically I took the example from the first link and tried it, it seems to be working fine)
private void Form1_Load(object sender, EventArgs e)
{
IActiveMenu menu = ActiveMenu.GetInstance(this);
ActiveButton button = new ActiveButton();
button.BackColor = Color.LightBlue;
button.Text = "One";
button.Click += button_Click;
menu.Items.Add(button);
}
private void button_Click(object sender, EventArgs e)
{
MessageBox.Show("Button clicked");
}
Note: This button doesn't seem to support transparent background, so it doesn't look quite as good as the button in chrome.

Related

Xamarin Forms Editor - Completed raised when the control gets unfocused

I'm currently working on the last part of my studying project and I have to implement a chat functionality. I then began by realizing it from a new project (faster for testing to me). However, I am facing something, I don't know if it's a bug but there is the situation:
First, the problem comes from the input, there are two controls I will take as example:
Entry
Editor
I would like to use Editor for its multiline capability, it makes it more readable to me (Maybe it's possible from a simple Entry, but that's not the point I wanna focus on).
I can type my text, everything is good, but it's when I want to send this text that my problem is. In fact, it doesn't seem possible to have a submit button in the keyboard (I couldn't make it), so I created a button (which is gray, at the right of the input).
When I click that Button, you and me agree that we 'unfocus' the Editor, so Unfocused is raised and the method attached public void OnInputUnfocused(object sender, FocusEventArgs fe) {} is called.
So my question is: Why Completed is called too?
I put the project on github: https://github.com/Emixam23/ChatAppExample
If you take a look at the README or just by scrolling down, you will see some information about it and how to try the two different behaviors between Entry and Editor
Thanks for any help!

The SettingsFlyout can not be displayed in Windows Phone 10

I created a custom SettingsFlyout. The SettingsFlyout appears properly when it runs in my Desktop. But when I run it on a mobile device, the SettingsFlyout does not appear. Here is the code:
private void SettingsButton_Click(object sender, RoutedEventArgs e)
{
var flyout = new TestSettingsFlyout();
flyout.Show();
}
The remarks at MSDN stands:
Caution SettingsFlyout is not supported for use in UWP apps for Windows 10.
Caution SettingsFlyout is supported only for use with the SettingsPane in Windows 8. While the SettingsFlyout type is visible in Windows Phone projects, SettingsPane is not present on Windows Phone, so use of SettingsFlyout is not supported.
Therefore this may be the problem.

BackButton Windows Phone 8 (VB)

I have a Program with 2 Frames ("MainPage" and "Inicio", "Inicio" is the first one on be opened).
"Inicio" Has a Link to open "MainPage" and, when the user is on "MainPage", I want to make an event that when the BackButton (the <- of the phone) is pressed, the Program go back to "Inicio", but instead of it, the program is suspended and the Phone go back to the Windows Home.
I'm working on VB and I can't find any tutorial or Event to VB, all that I found on google was to C# and I don't know how to convert code from C# to VB for now.
Please Note that I'm working with VB for Metro (Or VB For App Store) and I had to define the event on the XAML, and there is the problem, because, not like when we code on .VB, I don't have suggestion or error marks. I can write "aigwiuagwa_aiuwdaiu as Handler..." and for the builder that Event exists.
The problem is that I was ussing "Blank Page", and I needed to use "Normal Page". "Normal Page" has Navigation Helper that detects if there is another Page/Frame to go back or not. Another thing is that NavigationHelper has a lot of "#IF WINDOWS_PHONE_APP Then" and it doesn't detects that it is actually an Windows Phone Apps, so the Back Button doesn't works either. The solution was to Delete that IF, and below of then is allways an "ElseIf", the thing is to replace that "ElseIf" with "#IF WINDOWS_APP then". I needed to do it 3 times. Now my app is working fine.

Strange Copy/Paste behaviour WP 8.1

I'm developing a Windows Phone 8.1 universal app which allows the user to submit a link to a tweet.
From the Twitter WP app, select a tweet, then select the "copy link to tweet" context menu option.
Then paste that into a normal TextBox in my app and get the link followed by what appears to be Chinese characters. However, these appended characters are not consistent and vary with subsequent copy/paste.
Here are a couple of screenshots to illustrate the problem -
This is an odd one since it spans two distinct areas 1) the Twitter app itself and 2) WP 8.1.
When I paste this into Word it is fine. If I paste the same link into other TextBoxes on my page the strange characters vary.
Here is a couple of examples:
...twitter.com/TomMSFT/status/566885761476460544䓔
...twitter.com/TomMSFT/status/566885761476460544䊰灐ঔ佀玍㜀耀瑨搆玌搆
I've tried setting the Language property of the TextBox to the current culture of the phone (en-GB), no joy. This may be something the Twitter app is doing, if so, is there any way to filter out these characters when they are pasted into my app?
Anyway, this one has really got me scratching my head. Any ideas or help is appreciated.
UPDATE:
As an immediate workaround, I'm applying this solution to strip these out:
private void LinkTextBox_OnTextChanged(object sender, TextChangedEventArgs e)
{
LinkTextBox.Text = Regex.Replace(LinkTextBox.Text, #"[^\u0000-\u007F]", string.Empty);
}
Unfortunately this is a known issue with Windows Phone 8.1 apps pasting Unicode text. Some form of manual stripping (like your Regex) is needed.

Silverlight printing in web browser problem

I'm trying to print from a Silverlight application.
Printing works when I run the application Out Of Browser. But when I run it in the web browser, the Print dialog is shown but nothing happens when I click the buttons (Print, Cancel, or even close the window). I tried running without debugger attached (deployed to IIS) but it's the same thing.
The code:
private void PrintLabel()
{
PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += new EventHandler<PrintPageEventArgs>(printDocument_PrintPage);
printDocument.Print("Label for " + this.tbSerialNo.Text);
}
void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
e.PageVisual = this.csLabel;
}
Am I missing something?
This sounds like a browser-specific issue I have seen in the past. Are you running this in Firefox 3.6 or later? If so, this Firefox bug might be of some interest to you since the print dialog is a popup window as well.
You can fix this popup issue by setting dom.ipc.plugins.enabled to false in Firefox's about:settings menu. However, this sometimes causes mouse oddities, as described here.
If this is the case(and it sounds like it is), printing does work in Out-Of-Browser mode since its really just running Silverlight in an IE process without any toolbars.