|
I have a small function in my app that displays an HTML dialog that works find in Windows XP but not 98. Code is as follows:
<br />
void ShowExportTemplatePreview(HWND hwnd)<br />
{<br />
<br />
HINSTANCE hinstMSHTML = LoadLibrary(TEXT("MSHTML.DLL"));<br />
<br />
if(hinstMSHTML)<br />
{<br />
SHOWHTMLDIALOGFN *pfnShowHTMLDialog;<br />
pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*) GetProcAddress(hinstMSHTML, TEXT("ShowHTMLDialog"));<br />
<br />
if(pfnShowHTMLDialog)<br />
{<br />
char szTemplatePreview[MAX_PATH];<br />
wsprintf(szTemplatePreview, "%s\\Temp_0.html", cStartupData.szAppDirectory);<br />
<br />
WCHAR wcTemplatePreview[MAX_PATH];<br />
<br />
MultiByteToWideChar(CP_THREAD_ACP, NULL, szTemplatePreview, sizeof(szTemplatePreview), <br />
wcTemplatePreview, MAX_PATH);<br />
<br />
IMoniker *pURLMoniker;<br />
CreateURLMoniker(NULL, wcTemplatePreview, &pURLMoniker);<br />
<br />
if (pURLMoniker)<br />
{<br />
BSTR bstrOptions = SysAllocString(L"dialogHeight:30;dialogWidth:45;resizable:yes");<br />
<br />
(*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL);<br />
<br />
SysFreeString(bstrOptions);<br />
<br />
pURLMoniker->Release();<br />
}<br />
}<br />
<br />
FreeLibrary(hinstMSHTML);<br />
}<br />
}<br />
This is mostly copied from MSDN and I am trying to find compatibility issues with no success. We have pinpointed the problem to:
(*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL);
But i have no idea as to what is causing the error or how to even go about solving it. Does anyone have any experience with this function that could be of help? Thanks in advance.
|
|
|
|
|
You haven't said what the error is?
georgiek50 wrote:
We have pinpointed the problem to:
What problem - besides "not working"?
You aren't testing a) if the file exists, b) whether an appropriate version of MSHTML is being used, c) what ShowHTMLDialog() returns, d) whether the hWnd is valid.
FYI you should use the pre and code links on the Formatting bar below the mssage area when posting code.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
GetLastError() returns 0 and I don't know specifically which function to call to get this type of error (I'm very new to this stuff and can't find it in MSDN)
Not working means the dialog isn't opening. The file is there, MSHTML.dll is being loaded as well.
Thanks for the help.
|
|
|
|
|
|
Check your return values and init your pointers to NULL. Specifically, if CreateURLMoniker() fails, you don't look at its retval and pMoniker will be left as uninitialized (but non-zero) garbage, which you will treat as success.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
CreateURLMoniker returns S_OK. The only reason I know that it is failing at the specific line is that the HRESULT returned by ShowHTMLDialog != S_OK (I have tested all other return values). I guess the most important question from here is to find what error code exactly the function returns. That is what I can't find documentation on.
Thanks for the help.
|
|
|
|
|
I have a tree containing a large number of items, each leaf item has a PARAM attached to it ( pointer to its data )
Is there a better way to highlight items in the tree than just looping thru all items in it ?
for example, I have something like (pseudo code):
...
for ( myData; ++myData )
{
tree.highlightItem( myData, TVI_ROOT );
}
...
myTree::highlightItem( myDataType myData, HTREEITEM hItem );
{
HTREEITEM hCurrent = hItem;
while( hCurrent )
{
HTREEITEM hChild = GetChildItem( hCurrent );
myDataType* pData = (myDataType*)GetItemData( hCurrent );
if ( pData == myData )
{
SetItemState( hCurrent, TVIS_SELECTED, TVIS_SELECTED );
}
if( highlightItem( hChild, myData ) )
return true;
hCurrent = GetNextItem( hCurrent, TVGN_NEXT );
}
}
I can set the root item as close as possible to the leaf I'm looking for, eliminating as much recursion as possible, but if a sub-tree contains a very large amount of items,
Is there a better solution ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I would have thought iterating the (MS) tree would be too slow and isn't something you would typically want to do. Why not keep a pointer to the selected node in your mydata struct/class. Then no lookups are needed. You do however need to ensure the tree and your mydata are kept in sync.
IMO this is one of big problems using many MS controls as you need to double up on where data is stored and transfer stuff back and forth. It is far better if the control simply displays your data wherever and however it is stored. But I diverse.
The MS Tree Ctrl isn't all that fast, especially with large trees. Which is why I don't use it.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Neville Franks wrote:
Why not keep a pointer to the selected node in your mydata struct/class. Then no lookups are needed. You do however need to ensure the tree and your mydata are kept in sync.
I tried this, it works when the tree gets updated when the selected state of data is modified external of thh tree, but I have problems when changing the select items from within the tree itself.
Will keep trying to find what wrong with this.
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi,
I have a fairly large application (maybe 100-200K LOC or so), and the resources have been divided up into several sections depending on their role in the project. Lately (after we switched to Visual Studio .NET 2003) we've been experiencing problems with a single part of the resources (defined in a separate .rc file). I.e. no resources defined in this single file will get compiled into the application in release mode. Everything works fine in debug mode. This includes all resources; menus, bitmaps, string tables etc.
Has anyone had any similar problems? Any hints?
Best regards,
Daníel
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
hello friends
plz tell me that how i can write in a text file from a buffer. and how i can search text file offset so that while writing in a file it shld not rewrite in the same position but it shld write in the position specified.
thanx
|
|
|
|
|
Add ur header:
<br />
#include "fstream.h"<br />
To write to File "Title.txt", at end of file.
<br />
ofstream a_file ( "Title.txt", ios::ate, ios::app);<br />
a_file<< "Data";<br />
a_file.close();<br />
To read from File "Title.txt"
<br />
char idata[256];<br />
ifstream b_file ( "Title.txt" );<br />
while (! b_file.eof() )
{<br />
b_file.getline(idata,256);<br />
cout<< idata <<endl;
}<br />
Hope it Helps... Replace the "Title.Txt" or "Data" with a variable and dont use the ""'s and you can have it set by user. Does this help?
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
do i have to encrypt files by hand then send them through a ftp connection, or is there a special protocol that deals with this? what i want is my program to have some type of protection during it's path to an FTP server (sniffer protection mainly i'm on a LAN )
thx in advance
|
|
|
|
|
Do some research on SSL type FTP connections.. I think I have seen articles here on CodeProject
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I have a group of Buttons which I create at runtime. What I need to be able to do is add a ScrollBar to my form, which hides\shows the buttons that are in or out of my scrollable area. I have created a CScrollBar at runtime, but cannot generate a Message Handler to handle the scrolling. With the Buttons, I used ON_CONTROL_RANGE to specify the individual button ID, and do whatever I wanted with it. However I cant get a similar thing to work with my ScrollBar. Long winded description I know, just wondered if anybody had experienced anything similar.
|
|
|
|
|
Scroll bars send WM_HSCROLL or WM_VSCROLL messages to it's parent window.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi,
I want to calculate the used disk space for a particular folder or the given path. In my knowledge two API's avilable in VC++.
1. GetDiskFreeSpaceEx
2. using LPWIN32_FIND_DATA (FindFirstFile, FindNextFile)
if we use GetDiskFreeSpaceEx, it gives the root directory space only.
Suppose i want to calculate the used space in F:\xx\yy\zz means i have to use
recursive search for all the subfolders using FindFirstFile, FindNextFile and calculate the used space using LPWIN32_FIND_DATA structure. It takes more time.
Is there any other option avilable to get the directory space immediately.
Like Any Folder -> Right click -> Properties --- The windows give quick result. Windows also using some searching concept but they done quickly, I think they updated the information every time somewhere it may be registry or Shell.
Is anybody having any idea about ... plz write...........
Your valuable suggestions are always welcome ......
Regards,
inbha.
|
|
|
|
|
inbha wrote:
if we use GetDiskFreeSpaceEx, it gives the root directory space only.
Actually it reports the size of the volume.
inbha wrote:
Suppose i want to calculate the used space in F:\xx\yy\zz means i have to use
recursive search for all the subfolders using FindFirstFile, FindNextFile and calculate the used space using LPWIN32_FIND_DATA structure. It takes more time.
True.
inbha wrote:
Is there any other option avilable to get the directory space immediately.
None to my knowledge.
inbha wrote:
Like Any Folder -> Right click -> Properties --- The windows give quick result. Windows also using some searching concept but they done quickly,
Depending on the number of files and folders encountered, it can take several seconds and you can see the numbers incrementing as it goes.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I want to do something similar to Windows 2k's "Search for Files and Folders". Anybody know how it's done? Is it done with CScrollView with CEdit/CButton? How would I go about give CEdit box a 3d look? And get CButton to run?
|
|
|
|
|
If you are looking to get the exact types of controls used, use Spy++. Otherwise, you'll need to create and register your own search handler.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello,
I am trying to use CBitmapButton with four bitmaps but it is not working. The button shows up, but not the bitmaps. When I set the control's style to BS_OWNERDRAW as it has been suggested then the bitmaps still don't show..but also what used to be the button now becomes a flat grey area on the screen. I have also tried BS_OWNERDRAWN without and without BS_PUSHBUTTON and no luck.
CWnd* parent = CWnd::FromHandle(this->m_hWnd);<br />
BOOL success = m_BitmapButton.Create(("Play Section"), <br />
WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW,<br />
CRect(10,10,44,44), parent, 1);<br />
success = m_BitmapButton.LoadBitmaps(IDB_PLAYSECTIONU, IDB_PLAYSECTIOND, IDB_PLAYSECTIONF, IDB_PLAYSECTIONX);
Another even more important question is, why does CBitmapbutton need to be ownerdrawn? isn't the whole idea that I give the control four bitmaps and it takes care of applying the appropriate one according to wether the mouse moves over it, presses it etc?
Thanks
Aristotel
|
|
|
|
|
greekgoddj wrote:
Another even more important question is, why does CBitmapbutton need to be ownerdrawn? isn't the whole idea that I give the control four bitmaps and it takes care of applying the appropriate one according to wether the mouse moves over it, presses it etc?
The standard Windows button supports only one bitmap, which is displayed instead of the text on a regular button. To support four bitmaps, CBitmapButton uses owner-draw so it can display all four bitmaps and prevent Windows from drawing the standard button shape.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi Ryan...
I managed to track down CBitmapButton::DrawItem() and look at its code inside. So at least now I don't have to worry about taking care of the actual bitmap selection and drawing depending on the state.
I did however notice that that function never gets called. Setting breakpoints shows that it never gets called.
Thanks,
Aristotel
|
|
|
|
|
I'm trying to find out if it's possible, and if so, what's the best way of writing a C++ DLL to start a thread from a VB6 app? The VB6 app has a GetMail() routine that it does, but it hangs up the rest of the app while it's processing. I'd like to make a dll that I can send the GetMail() routine, then create some type of global variable in VB that the dll can access to let the VB app know when the thread is finished processing so that the user can't close the app before it's done processing. Any starts or links? Is this even possible?
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Hi, I need help with programming simple console registry viewer in c++. Im trying to get all keys, but no all subkeys as RegOpenKeyEx KEY_ENUMERATE_SUB_KEYS can. I dont want get out as
Software
Microsoft
Current version
Security
etc
Sam
but i need to get just
Sofware
Security
Sam
+values
Can anybody help me make this function, which will fast read registry as DIR in cmd?
|
|
|
|