|
IE can render gif/jpeg/png/bmp files with no prob.
Use "file:"/"res:"/"http:"/custom: moniker
Brian
|
|
|
|
|
Brian Shifrin wrote:
IE can render gif/jpeg/png/bmp files with no prob.
Use "file:"/"res:"/"http:"/custom: moniker
I don't want to load a bitmap I want to load a normal HTML page and save it to a bitmap but I want to do it programmatically and with no windows.
Todd Smith
|
|
|
|
|
I have a MSVC++ 6.0 program that creates a worker thread and then performs file I/O using CStdioFile class. It works fine in Windows 98 but when I try to run the same program on windows XP, it fails to be able to open the files. I looked at permissions and logged in as the sys admin but it still fails to open the files. Any ideas?
Chipg
|
|
|
|
|
::GetLastError == ?????
in debug
@err, hr = ?????
|
|
|
|
|
The error was 32 but nobody else has this file open as far as I know. The filename was obtained using the CFileDialog class in the User interface thread but as far as I can tell this dialog does not actually open the file. It just returns the path and filename for you to open later which I am trying to do in the worker thread.
|
|
|
|
|
Post the code that opens the file via CStdioFile.
Kuphryn
|
|
|
|
|
One Year ago one guy had this same problem like me now (his mail is not valid). I spend 6 days to analyse old threads from all mailing
lists and I could not find solution of my problem.
Question is: "How safely run thread from another thread under MFC."
Here is my sample program.
Only you have to do is put it to any MFC application and run.
When you break execution, this will appear:
DBG: Break command failed within 3 seconds.
DBG: Potential deadlock. Soft broken.
Main thread will stop on PumpMessage().
Always one thread from thread list stop in PumpMessage(). probably
main
thread.
it looks like this:
->> USER32! 77e11d6b()
CWinThread::PumpMessage() line 821 + 19 bytes
CWnd::RunModalLoop(unsigned long 0x00000004) line 3478 + 19 bytes
CDialog::DoModal() line 539 + 12 bytes
CMyApp::InitInstance() line 66 + 11 bytes
sometimes it stop after 15 loops, sometimes after 20000 loops.
When you press F10 nothing will happen.
Sometimes on thread list are 3 threads, sometimes only main thread.
This same effect I have after few hour of waiting.
Different is only m_mgCur:
After break it is: m_mgCur = 0x0f
After few hours waiting: m_mgCur = 0x219
I have no idea what it means.
My program should:
-- Run Master thread:
-- Master thread should run and stop Slave Thread every 6 seconds.
I have no idea how can I do that.
/*------------------------------------------------------------------------*/
in mfc dialog or mainfrm file:
Master Newobject;
--->> Press Start Button: NewObject.Start_Master();
--->> Press Stop Button: NewObject.Close_Master();
/*------------------------------------------------------------------------*/
file: my_problem.h
class Master{
public:
Master();
~Master();
bool Start_Master();
void Close_Master();
CWinThread* volatile p_Thread_Slave;
CWinThread* volatile p_Thread_Master;
protected:
bool Open_Slave();
void Close_Slave();
static UINT Thread_Slave(LPVOID adr);
static UINT Thread_Master(LPVOID adr);
HANDLE ReqestTerminateEvent_Master;
HANDLE ReqestTerminateEvent_Slave;
};
/*------------------------------------------------------------------------*/
file: my_problem.cpp
Master::Master(){
ReqestTerminateEvent_Master=CreateEvent(NULL,TRUE,FALSE,NULL);
ReqestTerminateEvent_Slave=CreateEvent(NULL,TRUE,FALSE,NULL);
ResetEvent(ReqestTerminateEvent_Master);
ResetEvent(ReqestTerminateEvent_Slave);
p_Thread_Master=NULL;
p_Thread_Slave=NULL;
}
Master::~Master(){
if (ReqestTerminateEvent_Master!=NULL) {
CloseHandle(ReqestTerminateEvent_Master);
ReqestTerminateEvent_Master=NULL; }
if (ReqestTerminateEvent_Slave!=NULL) {
CloseHandle(ReqestTerminateEvent_Slave);
ReqestTerminateEvent_Slave=NULL; }
}
/*------------------------------------------------------------------------*/
UINT Master::Thread_Master(LPVOID adr) {
Master *LPMaster=(Master*)adr;
if (LPMaster==NULL) return 1;
while(WAIT_OBJECT_0!=WaitForSingleObject(LPMaster->ReqestTerminateEvent_Master,200))
{
if (!LPMaster->Open_Slave()) {ASSERT(false);}
Sleep(3000);
LPMaster->Close_Slave();
Sleep(3000);
}
return 0;
}
UINT Master::Thread_Slave(LPVOID adr) {
Master *LPMaster=(Master*)adr;
if (LPMaster==NULL) { return 1;}
while(WAIT_OBJECT_0!=WaitForSingleObject(LPMaster->ReqestTerminateEvent_Slave,300)){}
return 0;
}
/*------------------------------------------------------------------------*/
bool Master::Open_Slave(){
if (p_Thread_Slave) return false;
ResetEvent(ReqestTerminateEvent_Slave);
p_Thread_Slave=AfxBeginThread(Thread_Slave,this,THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED,NULL);
if (p_Thread_Slave->m_hThread){
p_Thread_Slave->m_bAutoDelete=false;
p_Thread_Slave->ResumeThread();
} else {
ASSERT(false);
Close_Slave(); return false;
}
return true;
}
void Master::Close_Slave(){
SetEvent(ReqestTerminateEvent_Slave);
if (p_Thread_Slave){
DWORD dwCode;
if ( ::GetExitCodeThread( p_Thread_Slave->m_hThread,
&dwCode )
&& dwCode == STILL_ACTIVE )
{
WaitForSingleObject(
p_Thread_Slave->m_hThread, INFINITE );
}
}
delete p_Thread_Slave; p_Thread_Slave=NULL;
}
/*------------------------------------------------------------------------*/
bool Master::Start_Master(){
if (p_Thread_Master) return false;
ResetEvent(ReqestTerminateEvent_Master);
p_Thread_Master=AfxBeginThread(Thread_Master,this,THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED,NULL);
if (p_Thread_Master->m_hThread){
p_Thread_Master->m_bAutoDelete=false;
p_Thread_Master->ResumeThread();
} else {
ASSERT(false);
Close_Slave(); return false;
}
return true;
}
void Master::Close_Master(){
SetEvent(ReqestTerminateEvent_Master);
if (p_Thread_Master){
DWORD dwCode;
if ( ::GetExitCodeThread( p_Thread_Master->m_hThread,
&dwCode )
&& dwCode == STILL_ACTIVE )
{
WaitForSingleObject(
p_Thread_Master->m_hThread, INFINITE );
}
}
delete p_Thread_Master; p_Thread_Master=NULL;
}
/*------------------------------------------------------------------------*/
-----------------
Mariusz Zielinski brainiax@wp.pl
-----------------
brainiax@wp.pl
|
|
|
|
|
WOW! SORRY guys I did not know that it takes too many place ...
brainiax@wp.pl
|
|
|
|
|
Hello,
I am new to .Net and more of an old school programmer. I for the life of me can’t make srand() work in .Net. this is the line of code that has always worked for me in the past:
srand(time(NULL));
The Error I get is:
error C2365: 'srand' : redefinition; previous definition was a 'function'
And
error C2501: 'srand' : missing storage-class or type specifiers
Now that damn intellisense or however you spell it tells me that srand() will return an int when I hover my mouse over the function call. So I thought that the computer knew what was going on so I tried to catch that int in a variable only to be told:
error C2440: 'initializing' : cannot convert from 'void' to 'int'
So after searching many web sites and books the only way I can find to seed the rand() is with srand(). Have I been left in the dark? Has the call to the system clock changed? What is going on with my lousy srand() call?
P.S. I did include time.h and I have not redefined srand() or rand() at all. I am new to namespace std so maybe I have messed something up in there.
Thanks.
|
|
|
|
|
That still gives the same problem. Am I suppose to be using :: on the rand class? I tried that and it did not work, I also tried using it on noting just like you said. The little menu pops up and teases me that srand() exists but still no luck.
|
|
|
|
|
This is my basic header file that has:
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <fstream>
using namespace std;
I have:
#include <vector>
using namespace std;
in classes that do not use the my standard header file.
In my rand.h file where the problem is occurring I have:
#include <time.h>
that’s all.
|
|
|
|
|
I messed up that last post so lets try again.
This is my basic header file that has:
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <fstream>
using namespace std;
I have:
#include <vector>
using namespace std;
in classes that do not use the my standard header file.
In my rand.h file where the problem is occurring I have:
#include <time.h>
that’s all.
|
|
|
|
|
srand is defined in stdlib.h, so try to include that header in your project.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
I got it. I had placed srand() outside of a function so it thought it was definition. Thanks for the help.
|
|
|
|
|
Since I can't add an attachment, I will try to explain.
My tool bar has button that are 32X32 pixels.
I also added two edit boxes after the button.
The problem is that in order to add the edit box, you have to use a SEPARATOR as a place holder in the .rc file and now this separator is showing behind my edit box which is not as thick as the 32X32 buttons.
Got it ?
Shay
|
|
|
|
|
nop,
If I will do that, it will affect the size and location fo my Edit box that is on top of the separator.....
Any more ideas ?
Shay
|
|
|
|
|
|
Excellent !
Exactly what I was looking for.
Thanks.
|
|
|
|
|
I had no problem with:
_bstr_t *arr = new _bstr_t[10];
BSTR bstrName = L"Howard";
arr[0] = L"string_one " + _bstr_t(bstrName) + L" string_three";
arr[1] = L"string";
arr[2] = L"Moe";
arr[3] = L"Larry";
arr[4] = L"Curly";
TRACE("%s\n", (char *) arr[0]);
TRACE("%s\n", (char *) arr[2]);
TRACE("%s\n", (char *) arr[4]);
|
|
|
|
|
Me neither.
I checked the memory again and there are differences between creating _bstr_t using SysAllocString and not using it.
Not using SysAllocString has overwritten one of my other variables! That seems to be THE problem. Is there an easy way how to Alloc and Free all the variables regarding the internally use of pointers (_bstr_t wrapper class)?
I need to create long strings out of smaller ones. The length is variable.
|
|
|
|
|
Hi guys
How can I manage the right click message in a CListBox Control?
Best Regards
Dr.Pi
|
|
|
|
|
subclass it and handle it's WM_RBUTTONDOWN message
|
|
|
|
|
Oh , stupid of me. It was really easy.
Thanks a lot
Dr.pi
|
|
|
|
|
now it's me who has a question...
i need some information on how to retrieve the hardware's name by irq or the other way round!
any1 got an idea?
thx for every answer
Don't try it, just do it!
|
|
|
|
|
AFAIK,
Either you do it the no-brains VB-way and use WMI, or you do it the more low-level DDK way using... well, the NT Object API (not sure if that' documented though - you might need to go undocumented).
AFAIK there is no Win32 way (if you want to, you might read that as "MS never considered us Win32 developers 'worthy' to know this").
Sorry for the bad news, even that this is only AFAIK. Sucks, doesn't it.
|
|
|
|