|
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
|
|
|
|
|
Help!
this is really gettng me crazy...
Does no one know a method to move the coptiontree 40 pixels downwards from the top?
|
|
|
|
|
How can I print out a image that I have in my program?
|
|
|
|
|
I am trying to use source code called BOOST\TUPLE, and I get the following error.
Main.cpp
C:\IT 670\Mod 4\Example2b\boost/config.hpp(26) : fatal error C1083: Cannot open include file: 'boost/config/user.hpp': No such file or directory
Error executing cl.exe.
The files do exist and the paths are:
"C:\IT 670\Mod 4\Example2b"
"C:\IT 670\Mod 4\Example2b\BOOST"
"C:\IT 670\Mod 4\Example2b"\BOOST\TUPLE"
In my code below I use #include "boost\tuple\tuple.hpp", which the compiler is finding. But tuple.hpp uses 'boost/config/user.hpp' which the compiler does not know how to find.
I have used tools->options->directories to setup the directories so the project can find the desired files to no avail.
Any suggestion would be great. Thanks
The code is
#include <numeric>
#include <iostream.h>
#include <ostream.h>
#include <vector>
#include "boost\tuple\tuple.hpp"
//store count, sum, and sum of squares
typedef boost::tuple<std::size_t, double,="" double=""> Stats;
int main()
{
return 0;
}
|
|
|
|
|
For those who care. I discovered the student version of VC 6++ does not support the path syntax of boost.
|
|
|
|
|
Hi all,
I have a dialog application which on the main dialog I have associated a menu with it. I have then added appropriate Update methods to each of the menus, however when the user clicks on the menu I want the menu to then either have a tick or not depending on its previous state. Unfortunately I cant get this working, heres a code snippet:
void
MyDialog::
OnUpdateMyMenu1 ( CCmdUI* pCmdUI )
{
m_MyMenu1 = !m_MyMenu1 ;
pCmdUI->SetCheck ( m_MyMenu1 ) ;
}
the above code works on a doc/view applicationbut it doesnt on a dialog app, can anyone spot what I'm doing wrong and how to remedy it? (as an observation, I've noticed that if I set the menus default state to be checked and then click it during runtime then the check mark does go but I still cant get it to reappear)
cheers,
|
|
|
|
|
|
cheers, I'll give that a try,
Andy,
|
|
|
|
|