Skip to content

Commit

Permalink
1.0.60a
Browse files Browse the repository at this point in the history
- added application manifest, to request admin credentials -> for
topmost to work correctly (still did not work)
- fixed setting topmost - forcing it via win32 messages
  • Loading branch information
jtorjo committed Sep 2, 2015
1 parent 658bb7a commit 6a8da1d
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 13 deletions.
47 changes: 47 additions & 0 deletions LogWizard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
Expand Down Expand Up @@ -88,6 +103,12 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>app.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -98,8 +119,10 @@
<HintPath>packages\ObjectListView.Official.2.8.1\lib\net20\ObjectListView.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization.Formatters.Soap" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -235,6 +258,7 @@
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="Properties\app.manifest" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand All @@ -252,6 +276,7 @@
<None Include="docs\todo.txt" />
<None Include="icons\bug.png" />
<None Include="icons\bug_disabled.png" />
<Content Include="app.ico" />
<Content Include="logwizard.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand All @@ -262,6 +287,28 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
<Visible>False</Visible>
<ProductName>Windows Installer 4.5</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.58.0")]
[assembly: AssemblyFileVersion("1.0.58.0")]
[assembly: AssemblyVersion("1.0.60.0")]
[assembly: AssemblyFileVersion("1.0.60.0")]
69 changes: 69 additions & 0 deletions Properties/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<!-- taken from https://msdn.microsoft.com/en-us/library/windows/desktop/dn481241%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396#base.version_helper_apis -->
<!-- <assemblyIdentity version="1.0.0.0" name="MyApplication.app" /> -->
<assemblyIdentity
type="win32"
name="JT.LogWizard"
version="1.0.0.0"
/>


<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
nov 05, 2013: used to be "asInvoker"
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application Id="LogWizard">

<!-- taken from https://msdn.microsoft.com/en-us/library/windows/desktop/dn481241%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396#base.version_helper_apis -->

<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>

</application>

<!-- https://technet.microsoft.com/en-us/library/jj713466.aspx -->
<ApplicationId>LogWizard</ApplicationId>
<AppUserModelId>LogWizard</AppUserModelId>
</compatibility>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->
</asmv1:assembly>
Binary file added app.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions docs/history.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

- test on deleted settings file (do we get exception)

1.0.60a
- added application manifest, to request admin credentials -> for topmost to work correctly (still did not work)
- fixed setting topmost - forcing it via win32 messages


1.0.58
- toggle topmost - allow showing even if title is shown as well
Expand Down
34 changes: 30 additions & 4 deletions logwizardsetup/logwizardsetup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
}
"Entry"
{
"MsmKey" = "8:_65633CB2F15B47949BBA26A63700E785"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_900BA54346A2479085BF08862BE89061"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -253,6 +259,26 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_65633CB2F15B47949BBA26A63700E785"
{
"SourcePath" = "8:..\\icons\\app.ico"
"TargetName" = "8:app.ico"
"Tag" = "8:"
"Folder" = "8:_E297CB39A550491681319D6F014A659B"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_FE97592EE371AE93311B615D98612263"
{
"AssemblyRegister" = "3:1"
Expand Down Expand Up @@ -362,15 +388,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Log Wizard Setup"
"ProductCode" = "8:{775AE4B0-EF75-4747-8FCC-393B0B7EEDAC}"
"PackageCode" = "8:{BAF07951-B7D9-4229-8EC2-2F6A1C50C0B1}"
"ProductCode" = "8:{28165485-976F-4630-A57F-E110646CA576}"
"PackageCode" = "8:{B05BF4F0-9913-499A-AB87-DCB79FC421C5}"
"UpgradeCode" = "8:{0E5BB812-A969-415B-9362-F64234C67C4A}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:1.0.57"
"ProductVersion" = "8:1.0.60"
"Manufacturer" = "8:John Torjo"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
Expand All @@ -380,7 +406,7 @@
"Keywords" = "8:"
"ARPCOMMENTS" = "8:"
"ARPURLINFOABOUT" = "8:"
"ARPPRODUCTICON" = "8:"
"ARPPRODUCTICON" = "8:_65633CB2F15B47949BBA26A63700E785"
"ARPIconIndex" = "3:0"
"SearchPath" = "8:"
"UseSystemSearchPath" = "11:TRUE"
Expand Down
8 changes: 5 additions & 3 deletions ui/log_wizard.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions ui/log_wizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2032,9 +2032,6 @@ private void synchronizeWithExistingLogs_CheckedChanged(object sender, EventArgs
app.inst.save();
}

private void log_wizard_SizeChanged(object sender, EventArgs e) {
update_msg_details(true);
}

private void viewToClipboard_Click(object sender, EventArgs e) {
ui_context cur = cur_context();
Expand Down Expand Up @@ -2167,5 +2164,19 @@ private void toggleTopmost_Click(object sender, EventArgs e) {
private void log_wizard_Load(object sender, EventArgs e) {

}

private void log_wizard_SizeChanged(object sender, EventArgs e) {
update_msg_details(true);
// FIXME remember position - if Visible
}

private void log_wizard_LocationChanged(object sender, EventArgs e) {
// FIXME remember position - if Visible

}

private void log_wizard_Activated(object sender, EventArgs e) {

}
}
}
14 changes: 13 additions & 1 deletion util/util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,27 @@ public static string add_dots(string s, int max_dots) {

public static void bring_to_top(Form form) {
form.BringToFront();
form.Focus();
form.Activate();

form.TopMost = true;
form.TopMost = false;
}

// ... just setting .TopMost sometimes does not work
public static void bring_to_topmost(Form form) {
form.Activated += FormOnActivated;

form.BringToFront();
form.TopMost = true;
form.Focus();
form.Activate();
}

private static void FormOnActivated(object sender, EventArgs eventArgs) {
var form = sender as Form;
form.Activated -= FormOnActivated;
form.TopMost = true;
win32.MakeTopMost(form);
}
}
}
36 changes: 36 additions & 0 deletions util/win32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace LogWizard {

Expand Down Expand Up @@ -59,5 +60,40 @@ public static void SetMousePos(Point p) {
public static bool SetMousePos(int x, int y) {
return SetCursorPos(x, y);
}

[DllImport("user32.dll", SetLastError = true)]
public static extern bool BringWindowToTop(IntPtr hWnd);
[DllImport("user32")]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);


[DllImport("user32.dll")]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);

const UInt32 SWP_NOSIZE = 0x0001;

const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;

public static void MakeTopMost(Form form) {
IntPtr hWnd = form.Handle;

// backup - hopefully we don't need to do this, but just in case
BringWindowToTop(hWnd);
const int SW_SHOW = 5;
ShowWindow(hWnd, SW_SHOW);

SetForegroundWindow(hWnd);
SetForegroundWindow(hWnd);

SetWindowPos(form.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
}

}
}

0 comments on commit 6a8da1d

Please sign in to comment.