|
I could be doing this completely wrong. I am trying to put a web browser inside an already created window. The m_htmlview member is actually a c++ wrapper for the IWebBrowser2 interface.
m_htmlview.Create( NULL,
dwStyle,
CRect( 0, 0, theRect.Width(), theRect.Height() ),
&theBrowser,
KnListID );
m_htmlview.Navigate("http://localhost:10000",NULL,NULL,NULL,NULL);
Problem is that when the Create method is called, it causes a memory exception. Is there anything I need to call before Create to properly initialize it? Or is it just not possible to use the IWebBrowser on anything but a dialog or SDI/MDI.
|
|
|
|
|
CoInitialize has been called?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Its an ATL project, so yes. And just in case it wasn't, I put a call to CoInitialize right before Create and it did nothing.
It dies in this code
BOOL CWnd::InitControlContainer()
{
TRY
{
if (m_pCtrlCont == NULL)
here --> m_pCtrlCont = afxOccManager->CreateContainer(this);
}
END_TRY
It would seem that afxOccManager would be NULL, but it is a macro for AfxGetModuleState()->m_pOccManager
hope that helps.
|
|
|
|
|
So you're mixing ATL with MFC... maybe calling AfxEnableControlContainer in InitInstance will help?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
That worked. Thanks a ton!
|
|
|
|
|
I just recently noticed this remark in the MSDN Library:
[For] Windows 2000/XP: If CREATE_ALWAYS is specified as the value of the dwCreationDisposition parameter and FILE_ATTRIBUTE_NORMAL is specified as the value of the dwFlagsAndAttributes parameter, CreateFile will fail and set the error GetLastError reports to ACCESS_DENIED . In this case, set the value of the dwFlagsAndAttributes parameter to the ORed value of the FILE_ATTRIBUTE_HIDDEN and FILE_ATTRIBUTE_NORMAL attributes to avoid this error.
Now, IIUC, code that once used CREATE_ALWAYS with FLAG_ATTRIBUTE_NORMAL and worked correctly on Win9x and WinNT will now start to FAIL when run on Win2K/XP? That makes no sense to me, because it could break existing applications and code. This also means that I can only create new files if they are initially hidden from now on?
Also, that remark also conflicts with what is mentioned earlier in the page for CreateFile , because it says for FLAG_ATTRIBUTE_NORMAL : "The file has no other attributes set. This attribute is valid only if used alone."
Thoughts? (Note that I am not having any problems relating to this so far, nor have heard any reports.)
Peace!
-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
(Try Check Favorites Sometime!)
|
|
|
|
|
Tested this on XP, and file is always created - even if file with identical name already exists. Seems like problem with documentation.
HANDLE h = ::CreateFile("c:\\x.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD dummy;
CString strx;
strx.Format("%d", GetTickCount());
::WriteFile(h, strx, strx.GetLength(), &dummy, NULL);
::CloseHandle(h);
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Tomasz Sowinski wrote:
Tested this on XP, and file is always created
Yeah, I know it still works correctly; as I said, I am not having an problem. I am just wondering if anyone is actually experiencing the documented issue.
FWIW, this has been in the documentation at least since the October '01 edition...
Peace!
-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
(Try Check Favorites Sometime!)
|
|
|
|
|
I need a function that takes a Day-of-Year as an integer and converts it back to a day and a month, and returns the month and day as two integers.
|
|
|
|
|
could you be a little more detailed in your question, i dont follow what you mean by 'day-of-year'.. an example could help too..
do you mean the 153rd day of the year, finding what the actual date is like 05/13?
-dz
|
|
|
|
|
What I mean by day-of-year is this:
if I pass 3,15,2002 into a function i would take 3 and 15 and convert that into the number of the year that 3/15 translates to.
More importantly. I need to take a interger and pass it into a function ( say 74) and get what day and month that corresponds to. I am not using MFC, and need to do this w/o any special functions.
|
|
|
|
|
Have you checked COleDateTime or CTime ?
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
is right here. The representation that you are talking about is called the Julian day. The formulas listed on that page will convert Julian days to Gregorian calendar days and vice-versa.
--Dean
|
|
|
|
|
I would like to access a 2D array using pointers. I understand that
I could use function such as pointers to array of pointers to
achieve that. How do I actually do that? and how do I
allocate memory to it using new and delete function?
-Danny
|
|
|
|
|
int *ptrArray[10];
for(int i=0;i<10;i++)
{
ptrArray[i]= new int[10];
}
...
... whatever
...
for(i=0;i<10;i++)
{
delete [] ptrArray[i];}
-c
Cheap oil. It's worth it!
|
|
|
|
|
Thanks for the reply. I udnerstand that is for 1D pointers?
I have come across the code for 2D array pointers using
int **a; // a is a 2D array of size Col 10 x Row 5
int row = 5;
int col = 10;
a = new int*[row];
for (int i=0,i
|
|
|
|
|
oRion wrote:
Thanks for the reply. I udnerstand that is for 1D pointers?
No it was for 2D pointers.
int ** the_array is somewhat like int * the_array[10].
You see, the_array is just a pointer to the first element in the array.
When you say the_array[x] the compiler says: Ok, i take the memory offset of the_array and add the the size of an element times x and then i dereference (or whatever that is called) it.
So, when you declare the_array to be int ** the_array, then you say that you want a pointer to an object that can reside anywhere to a pointer to an object that can reside anywhere.
When you declare the_array to be int * the_array, then you say that you want a pointer to an object that resides on the stack that consists of pointer(s) to object(s) that can reside anywhere.
If an array is statically declared, then you can use the sizeof() operator to get the number of items, otherwise you have to remember the size yourself.
oRion wrote:
how do I actually delete it? I have tried to use
delete[] a;
If the 2D array was declared as you stated, then no, this is not sufficient. You have to traverse the rows and delete[] each column array first, then delete[] the rows array.
If on the other hand the array was declared as int * the_array[10], then you only had to delete[] the column arrays as the rows array is declared on the stack.
"It could have been worse, it could have been ME!"
|
|
|
|
|
Alrite.. I have a problem where i need to take C code that was written on the 16-bit version of Visual that ran on Win 3.x.. I am not familiar with some of the VBX(Now obsolete) controls that are used in this code. For example, I am running this code on Visual C++ 6.0 and it does recognize the VBX control 'CVBControl'.. I want to know if there is anyway that I could convert this code into the 32-bit Version without redesigning my entire project??
Any advice is good advice..
TIA
|
|
|
|
|
mtrack81 wrote:
I want to know if there is anyway that I could convert this code into the 32-bit Version without redesigning my entire project??
Yes. Either find a COM (ActiveX or whatever they're called this week) component that does the same thing, or re-implement it yourself. That way you could keep the overall design of the project.
Isn't life a bitch when trying to maintain binary-only stuff that has become obsolete? Wouldn't it have been much better if you had the source code to that control to bring it up-to-date? Maybe there's a reason why the GPL codebase is growing?
|
|
|
|
|
VBX controls were the 16 bit equilvent of OCX controls. You'll need to either find an upgraded version of your control or subsitute with a new control.
Michael
Errata 1: p. 154, section 'Defusing'. For 'red wire' read 'blue wire'.
|
|
|
|
|
Does anyone know the Equivalent of 'CVBControl' in VBX for either ActiveX or OCX??
|
|
|
|
|
mtrack81 wrote:
Does anyone know the Equivalent of 'CVBControl'
<sigh> Why can't people do their own googling before asking here?
It seems the CVBControl is some kind of VB (Visual Basic) wrapper control. As such, I'm fairly certain there is no equivalent for it. VBX'es died with Win16, and that was like... Um... Seven years ago.
Maybe if you look at how it's used/what it's used for you can get a better grasp of what is needed? What does it display/do? When you can answer that question perhaps you find there's already code written to do the same in Win32.
|
|
|
|
|
Mike Nordell wrote:
<sigh> Why can't people do their own googling before asking here?
Now, Now, CodeProject has always been a great learning place. So why not ask these types of questions here? You never know, maybe somebody else out there is having the same sorts of problems.
Nick
|
|
|
|
|
Nick Jacobs wrote:
So why not ask these types of questions here?
Because it displays they didn't even bother to google first?
But you are probably right. I was a little harsh. I'll try to wrap the old "do your own googling" in something fluffier next time.
|
|
|
|
|
How about: Please do your own freakin' googling?
|
|
|
|