Jump to content
  • Advertisement
Sign in to follow this  
ukdeveloper

Using manifest to give an app XP controls

This topic is 4885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to get my app to use the Windows XP controls and theme, but I'm not sure how it's done. All my app is is a dialog resource which gets loaded at runtime. There's no window being created programatically, just the dialog loaded. It's a standard Win32 app, no MFC, no .Net. I'm having trouble finding instructions for altering the manifest for my situation. How would I do it in my situation? Thanks in advance, ukdeveloper.

Share this post


Link to post
Share on other sites
Advertisement
I think you may need to look into GDI+. I'm not entirely sure if that is .NET only, but it might be worth checking out.

Share this post


Link to post
Share on other sites
Sorry guys, none of this seems to work. I'm using VC++ 2005 BETA, but I might just switch back to VC6 if it's going to be that much hassle.

You can't load resources in VC2005 without severe hackery.

Share this post


Link to post
Share on other sites
Here's the deal.

I'm linking to comctl32.lib, I've got <commctrl.h> included, and I'm calling InitCommonControls();

Here's my source file (unfinished program):


#include <iostream>
#include <windows.h>
#include <string>
#include "resource.h"
#include <fstream>
#include <cstdio>
#include <ctype.h>
#include <cstdlib>
#include <commctrl.h>

HWND LogonBox;
MSG MsgPump;

BOOL CALLBACK LogonProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
void ValidateInputs(int usrlen, int pwlen, char* usrbuf, char* pwbuf);
void WriteToDisk(char *usrbuf, char *pwbuf);
void encrypt(char *usrbuf, char *pwbuf);


int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nShowCmd)
{

InitCommonControls();

LogonBox=CreateDialog(hInstance,MAKEINTRESOURCE(ICARUS_LOGONFORM),LogonBox,(DLGPROC)LogonProc);

while( GetMessage(&MsgPump, NULL, 0, 0) )
{
if(!IsDialogMessage(LogonBox,&MsgPump));
{
/*TranslateMessage(&MsgPump);
DispatchMessage(&MsgPump);*/

}
}

return MsgPump.wParam;

}

BOOL CALLBACK LogonProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{

switch(msg)
{

case WM_INITDIALOG:

break;


case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case LOGONFORM_LOGON:
{
char *usrbuf,*pwbuf;

int usrlen=GetWindowTextLength(GetDlgItem(LogonBox,LOGONFORM_USERNAME));

int pwlen=GetWindowTextLength(GetDlgItem(LogonBox,LOGONFORM_PASSWORD));

usrbuf=(char*)GlobalAlloc(GPTR,usrlen+1);
GetDlgItemText(LogonBox,LOGONFORM_USERNAME,usrbuf,usrlen+1);

pwbuf=(char*)GlobalAlloc(GPTR,pwlen+1);
GetDlgItemText(LogonBox,LOGONFORM_PASSWORD,pwbuf,pwlen+1);

ValidateInputs(usrlen,pwlen,usrbuf,pwbuf); // Calls the validation function - checks for correct input
}
break;

case LOGONFORM_NEWACCLINK:
ShellExecute(LogonBox,"open","http://www.microsoft.com",NULL,NULL,SW_SHOWNORMAL);
return TRUE;
break;
}
}


break;

case WM_DESTROY:
DestroyWindow(LogonBox);
PostQuitMessage(0);
break;

case WM_CLOSE:
DestroyWindow(LogonBox);
break;

default:

return FALSE;
}


return TRUE;

}



void ValidateInputs(int usrlen, int pwlen, char* usrbuf, char* pwbuf)
{

if(usrlen>0 && pwlen>0)
{
encrypt(usrbuf,pwbuf);

}

else if(usrlen<=0)
{
MessageBox(NULL,"Please enter a username.","No username specified",MB_OK|MB_ICONSTOP);
}

else if(pwlen<=0)
{
MessageBox(NULL,"Please enter a password.","No password specified",MB_OK|MB_ICONSTOP);
}

}

void WriteToDisk(char *usrbuf, char *pwbuf)
{

char InputBuffer[100];

char delimiter[4]="$$";

sprintf(InputBuffer,"%s%s%s",usrbuf,delimiter,pwbuf);

MessageBox(NULL,usrbuf,"",MB_OK);

std::fstream UserList;

UserList.open("users.dat",std::fstream::out|std::fstream::binary);

if(!UserList)
{
UserList.open("users.dat",std::ios::in|std::fstream::binary);

}

else
{
UserList.close();

UserList.open("users.dat",std::ios::out);

}

UserList<<InputBuffer;

UserList.close();

MessageBox(NULL,"Logged.","Logged.",MB_OK);

PostQuitMessage(0);

}


void encrypt(char *usrbuf, char *pwbuf)
{

// PWD encryption algorithm to go here
WriteToDisk(usrbuf, pwbuf);

}




Here's manifest.xml, placed next to the exe:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="Icarus.EXE"
type="win32"
/>
<description>Icarus</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64664ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>




I just have no idea why this isn't working. The program compiles and loads fine, but just ignores all my settings and uses the Windows classic style, even though my machine is set to the blue XP theme. Nothing.

I've tried manually changing the Manifest settings in the Properties dialogue, but nothing again. To reiterate, I'm using Visual C++ 2005 Express Beta 2.

Stumped, and annoyed. This is why I'm not sure if programming's for me, simple things like this just never work for me, no matter the code I use.

[Edited by - ukdeveloper on July 30, 2005 6:52:48 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!