|
Sorry people ...
the code doesn´t have a call to Get application :
void CBitmapsView::OnPaint()
{
CPaintDC dc(this); // device context for painting
Graphics graphics(dc);
Bitmap *Bitmap_Res;
Bitmap_Res = Bitmap::FromResource(instance,L"BOTAO");
graphics.DrawImage(Bitmap_Res, 100, 100);
/*When instance is a global variable updated in CBitmapsView::PreCreateWindow*/
}
|
|
|
|
|
Every thing looks good, but you are not checking the return value of the FromResource() function. Are you sure that it is loading the bitmap? Do you have a bitmap named "BOTAO" or is BOTAO an integer that was defined in your resource.h file. If the later, use the MAKEINTRESOURCE() macro. Is instance the correct value? why not use AfxGetInstanceHandle() instead?
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hi PJ Arends ...
Yes I´m sure that it is loading a bitmap (At last it returns a non zero value). BOTAO is a integer that was defined in resource.h , so I´m a bit confuse because the documentation says:
=============================================================================
static Bitmap* FromResource(
HINSTANCE hInstance,
const WCHAR* bitmapName
);
Parameters
bitmapName
[in] Pointer to a null-terminated string that specifies the path name of the bitmap resource to be loaded. Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word. You can use the MAKEINTRESOURCE macro to create this value.
=============================================================================
I´ve tried to pass the parameter as a string . Haven´t I?
I re wrote the code using a local variable for instance, and I used AfxGetInstanceHandle() . But the window is still clear...:
void CBitmapsView::OnPaint()
{
CPaintDC dc(this); // device context for painting
HINSTANCE instance;
Graphics graphics(dc);
Bitmap *Bitmap_Res;
Bitmap_Res = NULL;
instance = NULL;
instance = AfxGetInstanceHandle() ;
if(instance==NULL)
{
MessageBox("instance=NULL","Error",MB_OK);
return;
}
Bitmap_Res = Bitmap::FromResource(instance,L"BOTAO");
if(Bitmap_Res==NULL)
{
MessageBox("Bitmap_Res=NULL","Error",MB_OK);
}
else
{
graphics.DrawImage(Bitmap_Res, 100, 100);
}
}
|
|
|
|
|
arturapps wrote:
BOTAO is a integer that was defined in resource.h
Bitmap_Res = Bitmap::FromResource(instance, MAKEINTRESOURCE(BOTAO));
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hello,
I know I'm doing something really stupid here but I can't figure it out.. I have a server app.. it spawns multiple client windows while it's running.. After I spawn a window I am trying to store a pointer to that window in a vector.. then once I decide to close the server window if any of the other client windows are open I want to close those too.. The reason I'm doing it this way is because all of the client windows have different names.. anyway heres the code.. anyone see anything wrong?
// In header
struct s_windows{
CWnd* pWnd;
};
std::vector<s_windows> v_windows;
// Adding a pointer to the just opened client window..
CWnd *pNewWnd = CWnd::FindWindow(NULL,_T("The Client App Name"));
if(pNewWnd)
{
s_windows sWindows;
sWindows.pWnd = pNewWnd;
v_windows.push_back(sWindows);
}
// IN Servers WM_CLOSE
std::vector<s_windows>::iterator iter_windows;
iter_windows = v_windows.begin();
while(iter_windows != v_windows.end())
{
s_windows sWindows;
sWindows = *iter_windows;
// IF WE HAVE A OPEN CLIENT WINDOW.. SEND IT A MSG TO CLOSE.
if(sWindows.pWnd)
{
sWindows.pWnd->SendMessage(WM_CLOSE,0,0);
}
iter_windows ++;
}
I must be storing the pointer wrong.. Any ideas?
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Rob, What exactly is the problem? I assume the Windows aren't being closed. Have you verified that the pWnd from FindWindow() is what you think it is. Also I wouldn't use a CWnd* here. FindWindow() may well be returning a temporary CWnd*. Far better to save the hWnd and do ::IsWindow() before doing WM_CLOSE. And finally I can't see the point of struct s_windows. I think the <> are missing from std::vector v_windows;
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Neville Franks, is corect.
1) Store the handle to the window insted of an object pointer, of unknow duration.
2) if(sWindows.pWnd) become if(::IsWindow(sWindows.hWnd))
One question:
If the windows, you are closing, are realy client windows, then why would you need to go thru all this trouble? (It should happen automaticaly.) The only reason for doing what you appear to be doing is if they are not client windows of your app.
INTP
|
|
|
|
|
Thanks to both of you for your replies.. I haven't tried your suggestions yet, I'm home now and not at work.. The reason for doing this as I am is that the client app is a totally separate exe. The server is a SDI and so is the Client..
I do a execute on the client window (with in the server), then right after that I do a FindWindow to get a CWnd pointer to that window.. I know the pointer is valid at that point because I do a WM_COPYDATA to the client window and display the results.. but then some of these windows get closed by the user and some stay open for the duration of the server.. I am looking to close all client windows when the server is closed. I'll look into another approach for this. It appears that the pointer is not valid anymore by the time the server is closed because none of the windows receive any of the send messages..
Thanks again.
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Thanks,
I'm back at work and I am storing the hWnd instead and using the IsWindow.. this works perfect.. Thanks everyone..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I maybe wrong here (as usual), but:
From looking into that line of code:
CWnd *pNewWnd = CWnd::FindWindow(NULL,_T("The Client App Name"));
I would assume that "The Client App Name" window doesn't belong to your module (it's not this module that created it).
If my assumption is true, then CWnd::FindWindow returns temporary CWnd object.
Therefore that temporary CWnd object maybe already deleted at the time you are using it later.
Solution:
Instead of storing CWnd* -- store HWND, like that:
struct s_windows{<br />
HWND hWnd;<br />
};
Regards
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Hi all,
How can i disable "WinLogo Key" in the KeyBoard Programmatically ? Also Ctrl+Alt+Del ?
Best Regards.
|
|
|
|
|
This has been discussed several times here at CP, and on the microsoft.public.vc.mfc newsgroup. As best as I can remember, neither is possible as they are intercepted by the keyboard device driver before being passed on.
|
|
|
|
|
|
I need to do it programmatically for 2 RichEdit's. When I press VK_DOWN in one the second shold scroll down too. How is it done?
|
|
|
|
|
If you are using Document/View and both windows are displaying the same document then you could use a document member variable to keep track of which line is displayed at the top of the window and then just call UpdateAll() when that value changes in one of your views.
INTP
|
|
|
|
|
I use nothing in MFC. I write an ATL component with 2 RichEdits so I need a way to do it in pure WinAPI.
|
|
|
|
|
You still have 2 options: 1) Maintain a window independent (scroll) position of the top left courner some where and then when the position changes in one window just invalidate the other window, or 2) When you you recieve a movement command in one window post the same message to the other window (this might require some translation or your part, but it shouldn't at the message should be in client coordinates).
Good Luck!
INTP
|
|
|
|
|
is there a way to use interrupts of parallel port directly in c++ .
i.e without using windows API CreateFile(),etc.
|
|
|
|
|
Depending on the OS, you may or may not (HAL) have direct access to the hardware.
|
|
|
|
|
Only by writing a device driver.
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"
|
|
|
|
|
Can anyone tell me if it is possible to use a controller
in Visual C++ to show a HTML page, like a web browser would
show it?
My application should show a html page, hopefully with fully
working links.
Hope someone can tell me or direct me to a tutorial!
thanx
|
|
|
|
|
Take a look at Paul DiLascia's CHtmlCtrl.
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
|
I want to implement a scroll window based on CWnd class. But I don't like use CScrollView. I try to display or set the scroll bar, but it doesn't work. Could you tell me some key points or give me some sample? Thanks.
|
|
|
|
|