|
Roger,
Thanks for this. The evidence suggests that this is what is happening. If I use the Old Style rather than Explorer style, I may catch the double click event? It still doesn't seem to work though.
|
|
|
|
|
Did you use of OFN_ENABLEHOOK and did you set lpfnHook ?
From the MSDN:
"If the OFN_EXPLORER flag is not set in the Flags member, lpfnHook is a pointer to an OFNHookProcOldStyle hook procedure that receives messages intended for the dialog box"
|
|
|
|
|
Yes, I did. I have the OFN_EXPLORER flag set, but all I was getting was the WM_NOTIFY message. This message doesn't notify of a double click, rather whether a file was selected, or a folder. I need the double click event.
|
|
|
|
|
I was working and searching for your question but I couldnt find an answer for it for example on this[^] thread someone asked like your question and it seems that he got an answer but I couldnt work with that answer.
|
|
|
|
|
I have to expose a BYTE pointer from activex control to exe. but I am not able to do that .can anyone help me.
S.Yamini
|
|
|
|
|
How many BYTES does the host executable need to access? The safe 'COM way' of doing this (if there are only a few bytes) might look something like this:
SAFEARRAY *pArrayVal = pdispparams->rgvarg[0].parray;<br />
<br />
if(NULL != pArrayVal && 0 < pArrayVal->rgsabound[0].cElements)<br />
{<br />
BYTE *pBytes = new BYTE[pArrayVal->rgsabound[0].cElements];<br />
<br />
if(NULL != pBytes)<br />
{<br />
char HUGEP *pArray = NULL;<br />
HRESULT hr = SafeArrayAccessData(pArrayVal, (void HUGEP * FAR *)&pArray );<br />
<br />
if (SUCCEEDED(hr))<br />
{<br />
memcpy(pBytes, pArray, pArrayVal->rgsabound[0].cElements);<br />
SafeArrayUnaccessData(pArrayVal);<br />
m_owner->FireEvent(pdispparams->rgvarg[1].lVal,pBytes,pdispparams->rgvarg[1].lVal,pArrayVal->rgsabound[0].cElements,1);<br />
}<br />
}<br />
delete[] pBytes;<br />
}
Essentially, you would send a copy of the bytes. If there is a very large amount of bytes to be copied or high performance was required then this method would be inferior.
Hope this helps,
-Randor (David Delaune)
|
|
|
|
|
Is creating a PCH file out of C header the answer to including a C header in C++ code?????
thankx
|
|
|
|
|
You can include a "C header" the same way you include any header file.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Let me ellobrate the Header is from the first project out of s 2 project solution
I sm getting all kinds of problem including this in my second project since it is depdent on other headers in the first project
This goes back to a question I posted on carrying over #define from the first project into the second
Maybe the answer to my problem is building a pch from this header in the first project and then just including it in the project??
thankx
|
|
|
|
|
Besides needing a path to the header file in a different project directory, I can't see why
there should be anything different.
What are the problems that are occurring?
I personally use separate folder(s) for any header files that will be shared between projects.
Then in my #includes, I do something like
#include "..\commonheaders\header.h"
The fact that they're "C" headers shouldn't matter. The Windows headers are C.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The first project was orignally developed under Linux so.... its a pure makefile project it has a buch of #define('s) for cygwin and other platform('s) etc...
When I include one of the headers in My project were I am trying to add code to my project a C++ MFC project I get a whle buch of complie errror(s) I figure while building the first project which contains this header that I trying to use I could compile it as a .pch (I think of a .pch as compling and linking a load module.. I am a Mainframe programmer and I am creating this add on project to try and teach myself C++ MFC or .NET)
Anyway I think of a .pch as compiled and linked load module ( I think that this is what the concept of .pch is about ???)
If I dont understand what the porpose of .pch is if you could enlighten me I would apperciate it ...
Thankx
|
|
|
|
|
I think the idea you have of using a .pch from one project in another project is not a good one.
If you cant or dont want to change the C header such that it looks like this
#ifdef __cplusplus
extern "C" {
#endif
lots of C stuff etc
#ifdef __cplusplus
}
#endif
then I cant see why using this in your C++ project wouldnt work
extern "C" {
#include "myCheader.h"
}
it essentially achieves the same end result after precompilation.
|
|
|
|
|
I tried that and still got compilation errors where the C project had a include file with a function prototype which the word "class" in it using it as a data name variable
In C using class as a data name varible is ok when I wrapped this header around the extern "C"
{
#include "cheader.h" }
still got compile errors
Why dont you think using .pch in this instance is not a good idea ???
|
|
|
|
|
The convention for precompiled headers in MFC projects is to have two files in your project directory stdafx.h and stdafx.cpp, stdafx.h contains all the common defines for the project and stdafx.cpp is the module upon which the precompiled header is formed.
I just noticed this statement in your previous comment "I sm getting all kinds of problem including this in my second project since it is depdent on other headers in the first project". I missed that the first time around.
You CAN NOT 'extern "C" { #include "myCheader.h" }' a header file that includes defines of classes because classes are NOT C defines they are C++ defines.
You need to identify exactly what the problem is.
|
|
|
|
|
Sorry,
I am trying to add a C++ /MFC/DLL project to a Solution which has one project a C makfile project this orignally was developed under Linux
Someone protted it to MSVC
I am including one header from the first project
I am getting all kinds of compile error('s) guess the header I am including is including other header('s)
Just thought one solution would be to precompile the header I am using in the first project and use it in my project
thakx hope this maakes sense
|
|
|
|
|
Hello,
I have used again one ActiveX Control that return IDispatch interface.
In application that is normal window Application i attach that interface by the way
MyView:IDispatch
{
.........
}
..........
in Mainframe.cpp
MyView view;
CAxWindow ctrlHost;
IUnknown *container = NULL;
ctrlHost.AttachControl(view,&container);
It working ok.But now i want to attach it into Doc/View but i don't know how to do it. I have try to use QueryInterface() but not success.Please Help me.
Thank's
-- modified at 3:47 Thursday 2nd August, 2007
|
|
|
|
|
On Windows XP/2000/NT as well as on Windows 98
How can we check programmatically whether current (or selected) printer is dot-matrix printer, InkJet or Laser ?
(Because end-user of application may have any type of Printer)
I appreciate any help or hint.
Ana
|
|
|
|
|
wow, great question... I have never tried this before.
The only thing I can think of... is getting the PRINTER_INFO_2 struct and checking the capabilities of the printer.
First get the default printer.
HANDLE CPrinter::OpenDefaultPrinter(ACCESS_MASK dwMask)<br />
{<br />
HANDLE hPrinter = INVALID_HANDLE_VALUE;<br />
PRINTER_DEFAULTS pDef;<br />
DWORD dwSize;<br />
<br />
ZeroMemory(&pDef, sizeof(pDef));<br />
GetDefaultPrinter(NULL, &dwSize);<br />
<br />
TCHAR* szBuffer = new TCHAR[dwSize];<br />
<br />
if(NULL != szBuffer)<br />
{<br />
if(GetDefaultPrinter(szBuffer, &dwSize))<br />
{<br />
pDef.DesiredAccess = dwMask;<br />
OpenPrinter(szBuffer, &hPrinter, &pDef);<br />
}<br />
delete szBuffer;<br />
}<br />
return hPrinter;<br />
}
Once you have the default printer... ou can populate a PRINTER_INFO_2 struct and look at all of the capabilities of the printer. I honestly dont know how to determine if a printer is dot matrix... but I have an idea...
I would think a dot matrix printer would probably have very low settings... low resolution... ect
Maybe something like this would work...
HANDLE hPrinter = OpenDefaultPrinter();<br />
<br />
if(INVALID_HANDLE_VALUE != hPrinter)<br />
{<br />
GetPrinter(hPrinter, 2, (LPBYTE)pInfo, 0, &dwNeeded);<br />
<br />
if(0 < dwNeeded)<br />
{<br />
pInfo = static_cast<PRINTER_INFO_2 *>(GlobalAlloc(GPTR, dwNeeded));<br />
if(NULL != pInfo)<br />
{<br />
if(GetPrinter(hPrinter, 2, (LPBYTE)pInfo, dwNeeded, &dwNeeded))<br />
{<br />
}<br />
}<br />
GlobalFree(pInfo);<br />
}<br />
ClosePrinter(hPrinter);<br />
}
Some other possibilities... DeviceCapabilities() in the MSDN: http://msdn2.microsoft.com/en-us/library/ms535506.aspx[^]
Maybe by reading what the printer is capable of you can determine if it *might* be a dot matrix. I have never tried this, let me know if you have any success.
-Randor (David Delaune)
|
|
|
|
|
To elaborate on what Randor said, do you have access to the various types of printers? If so, write a small program to show the attributes/properties/capabilities of each and compare. Surely you would find a value with a dot matrix that would be different from the others, or some setting with a laser that would be different from the others.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
If I add printers (just available drivers of printers in Windows XP), it allows to many of the queries even if printer is not available physically. So I will surely try if I can find something to identify printer type for sure.
Ana
|
|
|
|
|
I know when you have a external refrence to a C program in a C++ program you can decalre the function as extern "C"
however if in the same build in which you are building a C++ app you have a header that has inline C function('s) is there a way to let the compiler know that this is a "C" function and not C++
thankx
|
|
|
|
|
You can also use extern "C" like this in a header file
#ifdef __cplusplus
extern "C" {
#endif
lots of C style defines etc
#ifdef __cplusplus
}
#endif
Which enables you to use a header describing defines for a C DLL in either a C or C++ project.
It is the method Microsoft uses and also the method I use.
|
|
|
|
|
can I do
#ifdef __cplusplus
#include "cheader.h"
#endif
|
|
|
|
|
alberthyc wrote: No_of_Slider
Do you ever initialize No_of_Slider?
Which pointer is NULL?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi, that was solved....
in the OutputData, i accidentally put me->pbydata[i]=me->MySliders.Getpos();
after I change to pbydata[i]=me->MySliders.Getpos();
solved.
but now i got assertion errors after i start the thread...
"Original post":
hi, desperately need some help with my code....
I have mfc dialog that reads slider positions and store into a data array, then this data is passed to on signal output board onboard memory and output.
This output process should be continuous so i'm using a worker thread.
Also, by changing the slider position, the output from the board should be changed accordingly.
the code compiles and build succesfully. After I start using the program, i got problems.
Here's some of my code:
in CMyTestDlg.h:
class CMyTestDlg : public CDialog{
char* pbyData[2];
long lBufSize;
int No_of_Slider;
CWinThread* pThread;//worker thread
Static UINT __cdecl Start(LPVOID pParam);//thread function
CSliderCtrl m_Myslider[2];//create 2 slider variable
afx_msg void OnBnClickedButtonInitialize();//this is the initialize button
afx_msg void OnBnClickedButtonStart();//this is the start button
afx_msg void OnBnClickedButtonStop();//this is the stop button
void MemAlloc();
void FillBuffer(LPVOID pParam);//fill the data buffer
void OutputData(char* pbyData, long lBufsize,CMyTestDlg* me);
//....and some other variable and functions
in my CMyTestDlg.cpp
....//some initialization
void CMyTestDlg::MemAlloc(){
// ----- allocate memory for data -----
for (i=0; i<2; i++)
pbyData[i] = (char*) GlobalAlloc (GMEM_FIXED, No_of_Slider);
}
void CMyTestDlg::FillBuffer(){
// ----- fill the data buffers with data -----
for (i=0; i<2; i++){
OutputData (pbyData[i], No_of_Slider,this);
void CMyTestDlg::OutputData(char* pbyData, long lBufsize,CMyTestDlg* me)
{//store the slider position into the two data arrays
int i;
for (i=0; i< me->No_of_Slider; i ++){
pbyData[i]=(char*)me->MySliders.GetPos();
}
UINT __cdecl CMy61xxTestDlg::Start(LPVOID pParam){//Thread Function
int i;
CMyTestDlg* me=(CMyTestDlg*)pParam;
do{
me->OutputData (me->pbyData[i], me->No_of_Slider,me);
SpcSetPararm(....)//a library function provided, don't worry about this
i++;
if (i == No_of_Sliders)
i = 0;
}while(!ERROR)
//this function should be fine
void CMy61xxTestDlg::onBnClickedButtonInitialize(){
//after Inialization button being clicked, do some initialization.
...
MemAlloc();
FillBuffer();
}
CMy61xxTestDlg::onBnClickedButtonStart(){
//After Start button being clicked, worker thread starts and data ouputed
pThread=AfxBeginThread(Start,this,-1);
}
void CMy61xxTestDlg::onBnClickedButtonStop(){
Error=False;//cause the thread function loop to break
for (i=0; i<2; i++)
GlobalFree ((HANDLE) pbyData[i] );
}
After I press the initialize button, something went wrong and i have to break,
on the output window, i got bunch of:
First-chance exception at 0x00000000 in Test_Multithreading.exe: 0xC0000005: Access violation reading location 0x00000000.
AND STACK OVERFLOW!
and on the call stack:
the yellow arrow points at 00000000();
what could cause the stack overflow????
i think there's a memory problem, probably either is the Fillbuffer or the OutputData function, but i can't find out where the problem is.
I don't think there's a thread problem because the thread was not even started.
|
|
|
|