|
You're right, escaping the string isn't necessary unless it is a string literal. I was confused by the VS.net debugger, which puts a summary of the elements of the FILE structure beside the pointer, the first element of the FILE * happened to be "0(Bad Ptr)", but the FILE * itself was good. Err.. . maybe I just need more caffeine.
Now I know why nobody else on the net or discussion boards had problem...
Thanks for your time.
Hua-Ying
|
|
|
|
|
Hi,
I created an MDI doc/view application using the wizard. I wanted to have one document that stores some data. One view that has controls and displays the data in drop down lists etc (I achieved that by subclassing CFormView, it works). But now I want to add a view that displays some graphics (I can do that by override the CView and override the OnDraw()) but how do I make it use the same document as the other view? Making another document class doesn't make much sense in my design and also I'd need to communicate between 2 documents to share some data which I don't want to do.
Also I see the implementation of GetDocument() which simply returns m_pDocument. However I can't find this variable in any header file. And the MFC reference I have doesn't list it in the CView class. And any of the code generated by the AppWizard doesn't create any views explicitly. How can it the constructor is private. Yet it all works It's all magic.
Any ideas/help? Thanks.
|
|
|
|
|
You are doing something that does not mesh well with the doc/view architecture, and whenever you do that, you have to start digging into the behind the scenes stuff that Microsoft doesn't readily expose to you.
You might want to think about using an SDI setup, create it with a splitter window, then use your own management of added CDocument derived objects. It is sometimes easier to construct than to deconstruct the AppWizard code
|
|
|
|
|
I don't have much experience with MFC so it's hard for me to decide the best way to go about designing the GUI. I would rewrite what I have now if there was a better way (such as splitwindows you suggest).
I don't even care for the CDocument since I don't use files. I can manage the data myself. What I do need though is some place to put some controls and some place to be able to draw pixels (jpeg data, or even graphs that I generate). I don't like the Dialog based application so I need to override the CFormView in order to insert controls into my MainFrame unless there's another way. So if I split the window would I be able to use 2 different View objects? The example I have from Code Project uses the same view on both sides.
Also if I add a Picture control can I somehow draw within those bounds (easily)? Can I draw on the CFormView and still display controls that work (easily)? That would eliminate the need for 2 Views.
That's a lot of questions...Thanks.
|
|
|
|
|
You do need an SDI then. You don't need CodeProject on this one, just look in the MS Help files for CSplitterWnd and there is a pretty good description and examples right there
You use the original view and then add another view and overide your own GetDocument() for it. Then create some system to logically update them when needed to correspond with your data. I just save pointers to each view in the OnCreateClient where you set up your CSpitterWnd in CMainFrame. But you can also use a system of sending update messages (The proper but annoying way)
You don't necessarily have to use the Doc/View system, but it saves you some trouble. It takes care of recent file lists, "are you sure you want to save that..." etc. etc. If you tinker with it expect to have to do some extra work to take care of these details.
If you override OnOpenDocument OnSaveDocument you interrupt the doc/view system, and can handle it any way you want.
Personally I have never used straight doc/view as it restrictive and simplistic.
|
|
|
|
|
I'll try that.
Just to confirm the following code creates the views:
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(COneView), CSize(0,0),
pContext);
m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CAnotherView), CSize(0,0),
pContext);
You save the pointer to the created view by calling GetPane(row, col) correct?
|
|
|
|
|
|
I am trying to display three different bitmaps on my dialog form. On my dialog, I have designated 3 picture controls where these bitmaps should appear. I am having trouble using LoadImage to display the bitmap, however.
Here I create handles to each bitmap:
HANDLE PICTUREONE = ::LoadImage(
NULL,
MAKEINTRESOURCE(IDB_PICTUREONE),
IMAGE_BITMAP,
0,
0,
LR_DEFAULTCOLOR);
HANDLE PICTURETWO = ::LoadImage(
NULL,
MAKEINTRESOURCE(IDB_PICTURETWO),
IMAGE_BITMAP,
0,
0,
LR_DEFAULTCOLOR);
etc...
Then in a switch statement, I decide which bitmap to display for each control on my dialog...
switch (PictureToDisplayCondition)
{
case 1:
GetDlgItem(IDC_CONTROL1)->SendMessage(
STM_SETIMAGE,
(WPARAM) IMAGE_BITMAP,
(LPARAM) PICTUREONE);
break;
case 2:
GetDlgItem(IDC_CONTROL2)->SendMessage(
STM_SETIMAGE,
(WPARAM) IMAGE_BITMAP,
(LPARAM) PICTURETWO);
break;
case OAS_D_FULL_OPEN:
GetDlgItem(IDC_CONTROL3)->SendMessage(
STM_SETIMAGE,
(WPARAM) IMAGE_BITMAP,
(LPARAM) PICTURETHREE);
break;
default:
break;
}
I tried to pass AfxGetResourceHandle() as the first parameter in my LoadImage()function but I get an assertion error... Can someone tell me what I am doing wrong here? Thanks!!!!
|
|
|
|
|
Where does the error occur?
|
|
|
|
|
I moved the bitmap assigments to OnInitDialog and was able to use AfxGetResourceHandle(). Originally, I had declared them globally. It works now. I guess that is the reason?
|
|
|
|
|
I don't have enough information. It sounds right.
|
|
|
|
|
Hello,
When I can create region from some bitmap on C/C++ & Windows API?
|
|
|
|
|
I'm really getting mad when I see such a question! There is an article about that on CodeProject, and you will have to look for it. And always seek for articles before posting questions like this one!
Don't try it, just do it!
|
|
|
|
|
I am working with Visual Studio 6.0 Standard Edition - I have heard some bad comments on the IDE of C++.Net, etc, and the Standard Edition is limited to compiles that link to the MFC lib through DLL's and has some other drawbacks. Does anyone know if they still sell Visual Studio 6.0 Professional Version, or if an updated VC++ 6.0 comes with C++.Net?
I have checked Microsoft and other sales sites, but it is difficult to cut through the marketing BS and get real information.
What I am looking for is "unmanaged" C++ compile capability, that uses the latest drivers, specifically USB. Thanks for any information.
|
|
|
|
|
<br />
<br />
<br />
template <typename T><br />
void deleteItem(T arr[], int &size, T target)
{<br />
sortArray(arr, size);<br />
<br />
int index = 0;<br />
for(int i= index; i<size-1; i++)<br />
{<br />
arr[i] = arr[i+1];<br />
}<br />
size --;<br />
<br />
index = searchArray(arr, size, target);<br />
<br />
if (index == -1)<br />
{<br />
cout << "Error";<br />
}<br />
<br />
<br />
else <br />
<br />
<br />
<br />
}
grrrrr....for my last else statement I need somthing if the item does exist, then i am moving everything from that indedx to the end up one!
but I don't know how to write it...can someone help!!!!! then I am done!!!
|
|
|
|
|
I'm not quite sure what your code is doing, but this might get you close:
index = searchArray(arr, size, target);
if (-1 == index)
cout << "Error";
else
{
for (int i = index - 1; i < size - 1; i++)
arr[i] = arr[i + 1];
} So if the array initially had eight items in it and the item searched for was found at index 5, this would move item 5 to item 4, item 6 to item 5, and item 7 to item 6. Is that the intent?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
YES TOTTALLY...THANK U SO MUCH !!!! =)
|
|
|
|
|
Hello, I am trying a custom control for the first time. I have applied the method suggested by Uri Mellshior (http://www.codetools.com/miscctrl/custbutton001.asp)
on custom controls using a dll and an MFC wrapper front end.
I already have a FormView SDI type window and I need to create a box in which I can write some formatted text. I created the dll project within the workspace, and pretty much copied the code presented (except for the one error I found in the dll init function).
When I run, I get an error ( ) after the custom dll is loaded (as seen in trace window). The crash happens in CWnd::CreateDlgIndirect, dlgcore.cpp, at the assert(hWnd == m_hWnd). hWnd gets assigned earlier at
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
pParentWnd->GetSafeHwnd(), AfxDlgProc);
I checked all the parameters passed and they look ok, hWnd is still null, which causes the failed assertion. I can't step inot the call because I end up only in GetSafeHwnd and back out again.
Ideas greatly appreciated. I have setup my project to dynamically link libraries, if that makes a difference.
Thanks,
|
|
|
|
|
Hi All,
I'm new to the Bitmap related works in the VC++. I've a buffer pointer (BYTE *p) pointing to the RGB values of a bitmap image (bottom-up). I can save the the bitmap image to 24-bits. But, simultaneously I wish to save in 4-bit (16 colors) and 8-bit (256 colors) DIB bitmaps. Creation of palettes and index table are not known to me. Could you please help me how I can do it.
Thanks in advance.
-Ardhendu
|
|
|
|
|
Hi All,
I'm new to the Bitmap related works in the VC++. I've a buffer pointer (BYTE *p) pointing to the RGB values of a bitmap image (bottom-up). I can save the the bitmap image to 24-bits. Simultaneously I wish to save in 4-bit (16 colors) and 8-bit (256 colors) DIB bitmaps. Could you please help me how I can do it.
For 24-bit RGB image the code is :
--------------------------------
BITMAPFILEHEADER bfh;
memset( &bfh, 0, sizeof( bfh ) );
bfh.bfType = 'MB';
bfh.bfSize = sizeof( bfh ) + lBufferSize + sizeof( BITMAPINFOHEADER );
bfh.bfOffBits = sizeof( BITMAPINFOHEADER ) + sizeof( BITMAPFILEHEADER );
WriteFile( hf, &bfh, sizeof( bfh ), &dwWritten, NULL );
BITMAPINFOHEADER bih;
memset( &bih, 0, sizeof( bih ) );
bih.biSize = sizeof( bih );
bih.biWidth = lWidth;
bih.biHeight = lHeight;
bih.biPlanes = 1;
bih.biBitCount = 24;
bih.biCompression = BI_RGB;
WriteFile( hf, &bih, sizeof( bih ), &dwWritten, NULL );
WriteFile( hf, pBuffer, lBufferSize, &dwWritten, NULL );
CloseHandle( hf );
------------------
Thanks in advance.
-Ardhendu
|
|
|
|
|
I've used a PostMessage cmd to window from inside a service. It works fine when a user is logged in. However, the same code does not work when no one is logged into the PC (Win 2000). Any ideas? I'm simply send ing VK_RETURN to simulate a user hitting the return key on a dialog window.
|
|
|
|
|
A couple of things come to mind...
When there is no one logged in, there is no desktop, so who are you posting the message to ?
Where does this dialog window come from, if this is an app run by a user, then it won't exist when no one is logged on.
How do you know the dialog is visible when no one is logged on, so that it is able to receive the message ?
|
|
|
|
|
Hi!
I'm using the great COptionTree (http://www.codeproject.com/treectrl/coptiontree.asp)
So far no problems, but then I tried to combine it with a "Sidebanner" (http://www.kinkycode.com/?section=cppdev&sub=kcsidebannerwnd)....in order to have a small image [b]on top[/b] of my dialog..
But now i have the problem, that the optiontree "moves under" the bannerimage...
Now here my question..how can i set that the y-position of the optiontree "moves" 40 pixels downwards..?
I think the OnSize function is responsable for my problem..so here the code which i have in my dialog..:
Perhaps somebody can tell me the code, i have to add
void CPrefsDlg::OnSize(UINT nType, int cx, int cy) <br />
{<br />
if ((cx > 0) && (cy > 0))<br />
{<br />
if (::IsWindow(m_otTree.GetSafeHwnd()))<br />
{<br />
m_otTree.MoveWindow(0, 0, cx, cy);<br />
}<br />
}<br />
<br />
CPropertyPage::OnSize(nType, cx, cy); <br />
}code><br />
<br />
<br />
mfg<br />
Delphin
|
|
|
|
|
I had this problem too. I solved it my keeping track of the size of the every time the frame was resized and then using this integer to calculate the new size of the other frame using subtraction.
The simpler solution is switch the order, but much less challenging.
|
|
|
|
|
thanks for your reply...
as i'm not very advanced in c++, i would prefer a more easier method...
Isn't it possible to just make the optiontree "begin" 40 pixels downwards..?
isn't there a variable where i can set the (x;y) position of the tree like (0;40) ??
Perhaps you can post your code..or a short snippet which would help me a lot
thx
|
|
|
|
|