Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Linking styles statically
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Linking styles statically

 Post Reply Post Reply
Author
Message
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Topic: Linking styles statically
    Posted: 02 May 2006 at 10:41am

Is it possible to link the Office2007.cjstyles into the EXE?

Back to Top
rmercer View Drop Down
Groupie
Groupie


Joined: 22 February 2006
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote rmercer Quote  Post ReplyReply Direct Link To This Post Posted: 02 May 2006 at 11:40am

Why not add it as a resource to your project?  This will compile it into your .exe.  In your CWinApp::InitInstance() load the resource and write it to disk as a temp file (prior to creating your document template).  When your main FrameWnd is constructed and you call XTPSkinManager()->LoadSkin(), just pass in the temp pathname you wrote the skin file to.

I don't see any reason why this wouldn't work.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 02 May 2006 at 11:49am

Hi,

I guess it will work even without creating temporary file. Just specify your executable file in firsts parameter of LoadSkin.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 02 May 2006 at 3:30pm

Originally posted by oleg oleg wrote:

I guess it will work even without creating temporary file. Just specify your executable file in firsts parameter of LoadSkin.

Tried to add the .cjstyles file to the resources, but in CXTPSkinManagerResourceFile::Open the resource can not be found, the following line failes.

HRSRC hRsrc = FindResource(m_hModule, strFilePath, _T("TEXTFILE"));

I guess the problem is that the TEXTFILE resource is wrapped in the executable.

My executable \ cjstyles (executable) \ TEXTFILE resource

Then I've tried to add the "SkinFramework/Styles/Office2007/Office2007.rc" file to my resources, which results in "file not found: res\Office2007_Normal.ini" errors.

Should I add the cjstyles or rc file to my resources?

Back to Top
rmercer View Drop Down
Groupie
Groupie


Joined: 22 February 2006
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote rmercer Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2006 at 9:32am
Originally posted by ABuenger ABuenger wrote:

Tried to add the .cjstyles file to the resources, but in CXTPSkinManagerResourceFile::Open the resource can not be found, the following line failes.

HRSRC hRsrc = FindResource(m_hModule, strFilePath, _T("TEXTFILE"));

I guess the problem is that the TEXTFILE resource is wrapped in the executable.

My executable \ cjstyles (executable) \ TEXTFILE resource

Then I've tried to add the "SkinFramework/Styles/Office2007/Office2007.rc" file to my resources, which results in "file not found: res\Office2007_Normal.ini" errors.

Should I add the cjstyles or rc file to my resources?

Excuse any typos since I'm typing this in on the fly...

// CString m_strSkinTempFilename
HRSRC   hResource;
HGLOBAL   hGlbl;
LPVOID   hLockedResource;
long   l;
FILE   *fTemp;

if ( (hResource = FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MYSKINRESOURCE), _T("TEXTFILE")) ) != NULL)
{
 if ( (hGlbl = LoadResource(AfxGetInstanceHandle(), hResource) ) != NULL)
 {
  l = SizeofResource(AfxGetInstanceHandle(), hResource);
   if ( (hLockedResource = LockResource(hGlbl)) != NULL)
   {
    if ((fTemp = _fsopen(m_strSkinTempFilename, "wb+", SH_DENYWR)) != NULL)
    {
     fwrite(hLockedResource, 1, l, fTemp);
     fclose(fTemp);

    }
    DeleteObject(hLockedResource);

   }
   DeleteObject(hGlbl);
   
 }
 DeleteObject(hResource);

}

...

CXTPSkinManager()->LoadSkin(m_strSkinTempFilename);

...

Don't forget to delete the tempfile at shutdown, and you'll want to add some additional code to confirm that the skin was actually loaded.

Oleg's suggestion may work too, however I'm not familiar with what he's talking about, so I'll leave it up to him to assist you.

 

Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2006 at 9:46am

Thanks, but I would like to avoid to write the skin to a temporary file because that requires write permissions.

I hope Oleg has a suggestion how to load it directly from the EXE.

Quote Just specify your executable file in firsts parameter of LoadSkin.

Wouldn't that have the disadvantage that something that is already loaded is loaded (duplicated) again?

CXTPSkinManager::SetResourceFile looks promising.

 

Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2006 at 10:10am

Ok, I've added the Office2007.rc to my rc2 file, added "..\Source\SkinFramework\Styles\Office2007" to my include folders and it compiles and it loads the skin, but the result is not what I've expected:

That doesn't look like Office 2007 for me

Back to Top
rmercer View Drop Down
Groupie
Groupie


Joined: 22 February 2006
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote rmercer Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2006 at 11:32am
Originally posted by ABuenger ABuenger wrote:

Thanks, but I would like to avoid to write the skin to a temporary file because that requires write permissions.

Your users don't have write permission to their temp folder?  Okay, I'll let Oleg assist from here.

Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2006 at 6:23pm

I've figured out why it didn't worked, the problem is in CXTPSkinManager::LoadSkin

 BOOL bOffice2007 = CString(lpszResourcePath).Find(_T("Office2007")) > 0;
 m_pSchema = bOffice2007 ? new CXTPSkinManagerSchemaOffice2007(this) : new CXTPSkinManagerSchemaDefault(this);

I had to add "Office2007" to my executables name and then it worked fine.

Please change, overload or whatever it with CXTPSkinManager::LoadSkin(LPCTSTR lpszResourcePath, LPCTSTR lpszIniFileName, XTPSkin skin=xtpSkinOffice2007) or whatever...

 

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 2006 at 11:08am

Yes, right, please just change code now. For next vresion we will add SetShema method to allow you manually set CXTPSkinManagerSchemaOffice2007 class.

Thanks for this point.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 2006 at 1:00pm

Originally posted by oleg oleg wrote:

For next vresion we will add SetShema method to allow you manually set CXTPSkinManagerSchemaOffice2007 class.

Thanks, that would solve my problems, but is still not perfect. Users should be able to browse for *.cjstyles and *.msstyles skins, so wheter at compile nor at runtime I know the schema of the file.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 2006 at 4:53pm

Hello,

CString(lpszResourcePath).Find(_T("Office2007"))  will still present, so if user browse it it will use correct Schema....

I guess we will add parameter to ini file what shema to use.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 2006 at 5:28pm

Originally posted by oleg oleg wrote:

CString(lpszResourcePath).Find(_T("Office2007"))  will still present, so if user browse it it will use correct Schema....

That assumes that the file will not be renamed. What if the user renames Office2007.cjstyles to renamed.cjstyles?

Adding the schema to the ini file would be the best idea.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.