|
I write some code, but can't get result.
Bitmap* pBitmap = new Bitmap(L"bitmap1.bmp");<br />
<br />
TextureBrush* pTextureBrush = new TextureBrush(pBitmap);<br />
<br />
graphics.FillRectangle(pTextureBrush, 50,300,200,80);
or
CString str = _T("N00.bmp");
int strLen = 0;
strLen =str.GetLength();
WCHAR* ch = new WCHAR[strLen];
wcscpy(ch, CT2CW(str));
Bitmap* pBitmap = new Bitmap(ch);
TextureBrush* pTextureBrush = new TextureBrush(pBitmap);
graphics.FillRectangle(pTextureBrush, 50,300,200,80);
|
|
|
|
|
kk_Kevin wrote: ...but can't get result.
Why not? What is failing? What does FillRectangle() return?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I also don't know why, and it can not show nothing?
mybe the "bitmap::FromResource(..)" is wrong, and I do not know.
I try any way I can think out to resolve it, but, I can't
|
|
|
|
|
kk_Kevin wrote: mybe the "bitmap::FromResource(..)" is wrong, and I do not know.
Does it return a non-NULL value?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
first, the bmp pic "**.bmp" is in the res file of my project.
second, if I use Bitmap* pBitmap = Bitmap::FromFile(..); , the rectange can be filled. and use Bitmap::FromResource(..) can not.
thrid, I use ::FindResource(..) , but can not find the bmp
hInstResource = AfxGetApp()->m_hInstance;
src = _T("N00.bmp");
int strLen = 0;
strLen =src.GetLength();
WCHAR* ch = new WCHAR[strLen];
wcscpy(ch, CT2CW(src));
Bitmap* pBitmap = Bitmap::FromResource(hInstResource , CT2CW(src));
graphics.DrawImage(pBitmap, 75,35);
TextureBrush* pTextureBrush = new TextureBrush(pBitmap, WrapModeTileFlipY);
graphics.FillRectangle(pTextureBrush, 50,300,200,80);
Color m_penColor(233,100,54);
Pen pen1(m_penColor, 1);
graphics.DrawRectangle(&pen1, 50,300,200,80);
modified on Thursday, November 12, 2009 6:59 AM
|
|
|
|
|
kk_Kevin wrote: thrid, I use ::FindResource(..), but can not find the bmp
What does it return?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Is this C++ .NET (never developed in the language)?
If this is C++ .NET then I would think this will work (you have to check the syntax, cause of
my lack in skills in programming C++ .NET)
graphics.DrawImage(pBitmap, 50, 300, 200, 80);
Greetings
Covean
|
|
|
|
|
"graphics.DrawImage()" doesn't show any bmp pic
|
|
|
|
|
kk_Kevin wrote: "graphics.DrawImage()" doesn't show any bmp pic
What does it return?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have a Win32 Service (written in C) that does a CreateProcess(). After that it waits for its own termination (the services').
I would like to monitor the subprocess such that the service gets notified when the subprocess terminates (for whatever reason).
I have an idea of doing this with events and WaitForMultipleObjects(), but somehow I'm missing the idea where to start.
Should the service create an event? Or should the subprocess do that? And how would that be notified to the service process so that it can wait for that event?
Help very much appreciated.
--
Christoph
|
|
|
|
|
If I understand you right, you start some processes within your service and then you wanna wait till the processes ends?
If so, then I would use the handle hProcess from the PROCESS_INFORMATION you get by calling CreateProcess
and then use WaitForSingleObject or WaitForMultipleObjects.
Greetings
Covean
|
|
|
|
|
Thanks for answering. I thought so as well. Could you supply some sample code?
Does the -->>> WaitForSingleObject(pi.hProcess,INFINITE);
hang in that function call? Then I would not reach the
code section after it which already contains :
I think I have to create some sort of event and put it in the hEvents[] array.
if( !CreateProcess( NULL,
execpath,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi )
)
while(1) {
dWait=WaitForMultipleObjects(1,hEvents,FALSE,0);
if(dWait == WAIT_OBJECT_0)
break;
Sleep(1000);
}
cleanup:
if(pi.hProcess){
TerminateProcess(pi.hProcess,-1);
fprintf(logfile,"Subprocess %s terminated by service\n", execpath );
--
Christoph
modified on Wednesday, November 11, 2009 8:42 AM
|
|
|
|
|
A process handle acts as a kind of "event" and its fired if the process terminates, so you can add this handle to your hEvents array.
Does the -->>> WaitForSingleObject(pi.hProcess,INFINITE) hang in that function call?
Yes if you use INFINITE as time interval.
Here some code for you:
HANDLE hObjectsToWaitFor[2];
hObjectsToWaitFor[0] = hSomeEventHandle;
hObjectsToWaitFor[1] = pi.hProcess;
while(1)
{
dWait = WaitForMultipleObjects(2, &hObjectsToWaitFor, FALSE, 1000 );
switch(dWait)
{
case WAIT_OBJECT_0 + 0:
{
break;
}
case WAIT_OBJECT_0 + 1:
{
GetExitCodeProcess ( pi.hProcess, &procstat );
break;
}
default:
{
break;
}
}
}
[edit]
read the remarks section of WaitForMultipleObjects to see what kind of handles you also can wait for with.
(Examples: Event, Memory resource notification, Mutex, Process, Semaphore, Thread)
Greetings
Covean
|
|
|
|
|
Great! Many thanks. Just a minor drawback: When I stay in the while loop and the pi.hProcess has fired, the event sustains. Is there a way to reset the event automatically (or programmatically)?
--
Christoph
[edit]
I did the following (not sure whether it's correct):
while(1) {
dWait = WaitForMultipleObjects(2, &hEvents[0], FALSE, 1000 );
switch(dWait)
{
case WAIT_OBJECT_0 + 0:
{
goto cleanup;
break;
}
case WAIT_OBJECT_0 + 1:
{
timestamp(),fprintf(logfile,"Subprozess hat beendet mit exitcode %d, was tun?\n",
GetExitCodeProcess ( pi.hProcess, &procstat ));fflush(logfile);
ResetEvent(hEvents[1]);
hEvents[1]=NULL;
break;
}
default:
{
break;
}
}
}
modified on Wednesday, November 11, 2009 10:01 AM
|
|
|
|
|
You can try ResetEvent or change this event handle to an "empty" event you only create but never fire,
but I think the best way is to recreate the handle array without the process handle (be aware of that also the WAIT_OBJECT_0 + x value for all other events (after the process handle) changes if you remove this handle).
Here some pseudocode how I would solve this problem.
#define TIMEOUT_EVENT 0
struct WaitObject
{
HANDLE hWaitFor;
int nEventId;
}
int WaitForObjects(WaitObject[] waitObjects, bool bWaitAny, ....)
{
int nRetVal = 0;
int nLoop = 0;
HANDLE arrayWaitObjectHandles[waitObjects.Length];
for(; nLoop < waitObjects.Length; nLoop++)
arrayWaitObjectHandles[nLoop] = waitObjects[nLoop].hWaitFor;
nRetVal = WaitForMultipleObjects(waitObjects.Length, &arrayWaitObjectHandles, ...);
if(nRetVal == TIMEOUT)
return TIMEOUT_EVENT;
return waitObjects[nRetVal - WAIT_OBJECT_0].nEventId;
}
I know that this is not fully C (its too long ago^^) but I hope you understand the idea behind this,
just to build a function that waits for you and returns event ids (you assigned), so it will be easier
to remove the process handle from this array, because you waits for your assigned event ids.
I hope that helps.
PS: Viel Spass damit!
Greetings
Covean
|
|
|
|
|
Hi all,
I have changed my program Unicode based, from MBCS by changing in preprocessor. I have used all unicode supported syntex. Lastly it gives -
"cannot open file "mfc42ud.lib"
Can any one tell me why it is?
Thanks
|
|
|
|
|
|
Hi,
I have apply all this things. But it does not work. Can you tell me, which component will i install from visual studio cd.
|
|
|
|
|
Your original message statest that mfc42ud.lib could not be found. Have you istalled all the MFC libraries? Check the various library directories that are set in Visual Studio.
|
|
|
|
|
Did you run a search on your hard disk to see if mfc42ud.lib is actually present somewhere?
-Suhredayan
|
|
|
|
|
Hi,
Shaheen.India wrote: Can any one tell me why it is?
If I remember correctly... Visual Studio 6 did *not* install those Unicode MFC DLL's by default. When you install VS6 you need to navigate through the install choices and add the unicode DLL's. I would recommend getting your VS6 CD and modifying your installation.
Best Wishes,
-David Delaune
|
|
|
|
|
I am working on Excel Automation.
Application is MFC application without GUI.
All callbacks work perfectly in machine where office version is 2007 but same is not working in 2003.
When checking Excel.tli or tlh in both the machines, the size is different and AfterCalculate call back is missing in tli and tlh.
What needs to be added to application, to make it work for both versions.
This is how I imported:
#import "libid:00020813-0000-0000-C000-000000000046" auto_search no_dual_interfaces \
rename("DialogBox", "excelDialogBox") \
rename("RGB", "excelRGB") \
rename("DocumentProperties", "excelDocumentProperties") \
rename("SearchPath", "excelSearchPath") \
rename("CopyFile", "excelCopyFile") \
rename("ReplaceText", "excelReplaceText")
Please give me clue.
Regards,
KTTransfer.
|
|
|
|
|
try this one
#import \
".\MSO.DLL" \
rename("DocumentProperties","DocumentPropertiesXL") \
rename("RGB", "RGBXL")
#import \
".\VBE6EXT.OLB"
#import ".\EXCEL.EXE" \
rename("DialogBox", "DialogBoxXL") rename("RGB", "RGBXL") \
rename("DocumentProperties", "DocumentPropertiesXL") \
rename("ReplaceText","ReplaceTextXL") \
rename("CopyFile","CopyFileXL") \
exclude("IFont","IPicture") no_dual_interfaces
|
|
|
|
|
No its not working.
AfterCalculate event is introduced in office 2007.
So its not available in 2003.
But is there any way to get it by including any thing in application which works for both the versions.
If any idea.. .
Thanks in advance.
Regards,
KTTransfer.
|
|
|
|
|
ok it's working fine for me.But any way can you tell what you want to do?
|
|
|
|
|