|
It isn't, by definition.
From Here[^]
When creating the modal dialog box, the system makes it the active window. The dialog box remains active until the dialog box procedure calls the EndDialog function or the system activates a window in another application. Neither the user nor the application can make the owner window active until the modal dialog box is destroyed.
What you need is a "modeless" dialog.
Steve T
|
|
|
|
|
Unfortunately, I don't have the luxury of making every dialog modeless. I have, however, figured out a way to defeat the disabling of the parent (EnableWindow) that the modal dialog does. I've overridden the ON_WM_CANCELMODE and ON_WM_ACTIVATE callbacks within the mainframe. Doing so, I know when a modal dialog is invoked, since the OnCancelMode is invoked. Then when the OnActivate is invoked, letting me know the frame has become inactive, I can EnableWindow(TRUE) the mainframe and then the modal dialog behaves like a modeless. But, I don't want the entire app to be accessible by the user... just the items within the controlbar. Thus, I'm looking to see if anyone has figured out a nice way to work around the issue.
|
|
|
|
|
Hi all,
I'm developing an extension to Explorer on windows 2000 and I want to insert an icon in my option of the context menu. Everything is already working but the icon. Only to clarify, I want to do exactly the same WinZip does on the context menu (insert an option with an icon). Does anybody has an example of how I do this?
Thanks,
Luiz.
|
|
|
|
|
|
I created a template class like
template <class T><br />
class CProtectedBuffer <br />
{<br />
public: <br />
int DeQueue(T &cElement);<br />
int Enqueue(const T &newElem);<br />
CProtectedBuffer();<br />
virtual ~CProtectedBuffer();<br />
private :<br />
void Enter();<br />
void Leave();<br />
CRITICAL_SECTION cs ; <br />
T t[MAX_PBUF_SIZE] ; <br />
int objCount;<br />
<br />
int headIndex ;<br />
int tailIndex;<br />
int size ; <br />
<br />
};
Now I want to reuse this template to store objects of a custom class which is :
<br />
<br />
class RcvBuffer{<br />
<br />
public : <br />
RcvBuffer():toolName(""),buffer(0),packetSize(0)<br />
{<br />
}; <br />
~RcvBuffer(){<br />
if(buffer){<br />
delete buffer ;<br />
buffer = 0 ; <br />
}<br />
};<br />
<br />
const RcvBuffer& operator=(const RcvBuffer &rhs)<br />
{<br />
if(buffer){<br />
delete [] buffer ; <br />
buffer = 0;<br />
}<br />
int sz = rhs.GetPacketSize() ; <br />
if(sz){<br />
toolName = rhs.GetToolName();<br />
packetSize = sz ; <br />
buffer = new UINT8[sz] ;<br />
for(int i=0;i<sz;i++){<br />
buffer[i] = rhs.BufferValueAt(i);<br />
}<br />
} <br />
return (*this); <br />
<br />
};<br />
<br />
const int GetPacketSize() const <br />
{<br />
return packetSize ; <br />
};<br />
<br />
const UINT8 BufferValueAt(const int &index) const <br />
{<br />
if(index<packetSize ){<br />
return buffer[index];<br />
}<br />
return 0;<br />
};<br />
const string& GetToolName() const <br />
{<br />
return toolName;<br />
};<br />
<br />
int Clear() <br />
{<br />
if(buffer){<br />
delete buffer ;<br />
buffer = 0 ; <br />
}<br />
packetSize = 0; <br />
toolName ="";<br />
<br />
};<br />
private : <br />
string toolName ;<br />
UINT8 *buffer ;<br />
int packetSize ; <br />
};
Here is the part implementation of the template class
template <class T><br />
CProtectedBuffer<T>::CProtectedBuffer():headIndex(0),tailIndex(0),size(0)<br />
{<br />
::InitializeCriticalSection(&cs);<br />
<br />
<br />
<br />
}<br />
template <class T><br />
CProtectedBuffer<T>::~CProtectedBuffer()<br />
{<br />
..<br />
..<br />
..<br />
}
I am using the code like
CProtectedBuffer<RcvBuffer > bBuff ;
I am getting the following linker errors :
linking...<br />
<small>EepromServer.obj : error LNK2001: unresolved external symbol "public: __thiscall CProtectedBuffer<class RcvBuffer>::CProtectedBuffer<class RcvBuffer>(void)" (??0?$CProtectedBuffer@VRcvBuffer@@@@QAE@XZ)<br />
EepromServer.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CProtectedBuffer<class RcvBuffer>::~CProtectedBuffer<class RcvBuffer>(void)" (??1?$CProtectedBuffer@VRcvBuffer@@@@UAE@XZ)<br />
Debug/EepromServer.exe : fatal error LNK1120: 2 unresolved externals<br />
Error executing link.exe.</small>
If someone can advise
|
|
|
|
|
Do you have the implementation part of CProtectedBuffer in a .cpp of its own? If so, it's no wonder that the linker misses those definitions: templates must de declared and defined in a header file to be included by the user code. Try moving all the CProtectedBuffer implementation stuff to protectedbuffer.h (or whatever the header is named), drop protectedbuffer.cpp and please check if things improve.
To be strict, it is not exactly true that templates must be defined in their header file, but this rule will work 100% of the time. If you're really curious about how templates definitions are located and instantiated, google for "template compilation model" (warning, the issue is rather technical.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Joaquín M López Muñoz wrote:
Do you have the implementation part of CProtectedBuffer in a .cpp of its own? If so, it's no wonder that the linker misses those definitions: templates must de declared and defined in a header file to be included by the user code. Try moving all the CProtectedBuffer implementation stuff to protectedbuffer.h (or whatever the header is named), drop protectedbuffer.cpp and please check if things improve.
yes the code links properly , but still I cannot fathom why the linker cannot get the implementation ? I recollect having once developed a generic Linked List class and am pretty sure I had a separate implementation File .
Anyways this works and really appreciate your help
|
|
|
|
|
Hi all,
I want to detect the computers in a star network using winsok2 or winsock,
and also I want to send a message to these computers without having any client program.
Please help me,
Thanks.
|
|
|
|
|
dSolariuM wrote:
I want to detect the computers in a star network using winsok2 or winsock...
How about NetServerEnum() ?
dSolariuM wrote:
...I want to send a message to these computers without having any client program.
And NetMessageBufferSend() ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi
I am developing an application using multi threading concept in Win32 Service which runs on Windows2000 Server.
Here I have used memcpy() function to copy one structure into another.
But it doesn't seems to be copying anything. What seems to be the problem. I have used all the parameter properly. It doesn't gives any message but still it doesn't show anything which needs to be printed.
e.g
=============
struct UsrProfile
{
int a;
int b;
char *str;
char *MainStr;
}
MasterServiceThread(CClass *objPassed)
{
UsrProfile UsrDlts;
Create ChildThread here...
Retrieve details for structure....
UsrDlts.a = 10;
UsrDlts.b = 11;
UsrDlts.str ="Mahesh";
}
ChildThread(CClass *objPassed)
{
UsrProfile Usr;
memcpy(&Usr, &ObjPassed->UsrDlts, sizeof(UsrProfile));
....blah blah....
}
Here it doesn't coping the data that needs to be copied into Usr structure object..
Any idea why it happens....?
Thankx in advance
Mahesh
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
Amarelia wrote:
Here it doesn't coping the data...
How are you verifying this?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I m veryfing by printing data of structure after copying...i.e Usr.a, Usr.b, Usr.str...etc...and it gives nothing....
Is there any other function to copy data from one structure to another structure..?
Thankx for your previous reply.
Mahesh
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
Is it possible that you are battling a race condition by viewing the contents of the structure before it has had a chance to be copied? Try your same structure-copying code in a single-threaded application and note the results. Hopefully that'll let you know if it is a thread-related issue or not.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello everybody:
I have a problem when compile a program with creates a thread specific hooh
I try to save the value of SetWindowsHookEx into a HHOOK var type
but when i compile the code the compiler gives me an error...
The error says:
error LNK2001: Unresolved external symbol" public: static HHOOK hhookMyHook
i'm making a class with the declaration of the HHOOK variable, it's of public type and i'm calling it from a function into the class
Why is happens????
|
|
|
|
|
You've not provided enough information so my answer is merely a guess.
HHOOK hHook;
...
LRESULT CALLBACK MouseProc( int nCode, WPARAM wParam, LPARAM lParam )
{
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
...
hHook = SetWindowsHookEx(WH_MOUSE, MouseProc, NULL, 0); How does yours differ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Excuse me, i forgot the rest of the explain...
my code differs in what all these declaration are into a class and the HHOOK is static type...
all of these are public type...
|
|
|
|
|
Savior999 wrote:
my code differs in what all these declaration are into a class and the HHOOK is static type...
all of these are public type...
Makes no difference:
class MyClass
{
public:
static HHOOK hHook;
static LRESULT CALLBACK MouseProc( int nCode, WPARAM wParam, LPARAM lParam )
{
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
MyClass()
{
hHook = SetWindowsHookEx(WH_MOUSE, MouseProc, NULL, 0);
}
}; BTW, public and static are mutually exclusive identifiers.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
the problem i what when i try to implement the body of the declaration into the class the compiler raise the mentioned error
may by i don't know how call the variable
class myClass{
static HHOOK myHook;
static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
myClass();
};
static LRESULT CALLBACK myClass::MouseProc(int nCode, WPARAM wParam, LPARAM lParam){
return CallNextHookEx(myClass::hHook, nCode, wParam, lParam);
};
myClass::myClass(){
myClass::hHook = SetWindowsHookEx(WH_MOUSE, myClass::MouseProc, NULL, 0);
}
this is an example code of what i have...
|
|
|
|
|
To initialize static members from outside of the class declaration requires a slight change. See here for details.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I found this page to display a bitmap and it works fine, but I need to replace each pixel value from a decompression routine done elsewhere in my app. In the broadstrokes, I'll open a bitmap image, send the bitmap data to be compressed, it'll be decompressed locally, then display the result. I can send the data fine and the decompression is no problem, but I need to display the decompressed result. I'm thinking I can open the image to fill the bitmap structure with the data it needs, then just drop in my decompressed data, then continue with the second half of the code to display the image. I can't seem to find any pages anywhere about this specifically because most projects only display images or maybe even change the palette values, but nothing as specific as what I'm trying to do. I tried to look at where the bitmap data is stored, then just allocate a chunk of memory the same size and just point to my new decompressed data rather than the data from the file but I couldn't locate that. Any help would be appreciated, thanks in advance, Nate.
|
|
|
|
|
the easiest way is to use something like StretchDIBIts.
you'll need to allocate enough memory for your pixels, with each row padded to a multiple of four bytes. then drop your pixels into the rows (in top-down order) - pixels arranged in Blue, Green, Red order. then fill out a BITMAPINFOHEADER structure and hand that to StretchDIBits. this is essentially making a DIB from your pixel data (though a true DIB would have the BMIH struct and pixels in a single buffer). and if you can do that, you're a BITMAPFILEHEADER away from a .BMP file.
well, actually, the easiest way is to run through your pixels and call SetPixel for each, but that's really slow.
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
I'll only be dealing with 8-bit bitmaps. I already wrote the routines to open a bitmap file and read in all the data (2 headers and palette data) myself because I needed to access the actual bytes and that works fine. I figure I can just take those 2 filled out headers I made and hand it to StretchDIB like you mentioned.
|
|
|
|
|
I am getting a runtime error that an edit box variable on a dialog cannot be evaluated.
I am not seeing what the problem is and would appreciate it if someone can point it out to me.
There is a global variable declared as:
<br />
double currentBP;<br />
In the first initDialog of the program, currentBP is initialized.
Class CGetNewBP displays a dialog. There is an edit box for the user to enter a value. It is declared as:
<br />
double m_newBP;<br />
When the user clicks OK on this dialog, the value entered into the edit box is transferred to the global currentBP.
On another dialog, there is a button - Change BP. When this button is clicked, the
CGetNewBP dialog is displayed as modal. On return, the global currentBP which was just
updated is assigned to an edit box declared:
<br />
double m_currentBP;<br />
At this assignment, however, an exception is raised saying that m_currentBP cannot be
evaluated. If I comment out the call to create and display CGetNewBP, the code executes
without exception, and m_currentBP displays the initialized value of the global currentBP.
When the display CGetNewBP code is in, and execution is broken at the assignment statement,
the value in the global currentBP has been updated correctly.
<br />
void CModeCtrlDlg::OnBnClickedChangeBP ()<br />
{<br />
CGetNewBP getNewBP = new CGetNewBP;<br />
INT_PTR nResponse = getNewBP.DoModal();<br />
delete getNewBP;<br />
m_currentBP = currentBP; <- error message that m_currentBP cannot be evaluated<br />
UpdateData(false);<br />
}<br />
Without the first 3 lines, no error message and m_currentBP accepts the assignment
and displays on the screen.
I have tried further qualifying m_currentBP as CModeCtrlDlg::m_currentBP, with no success.
|
|
|
|
|
theFrenchHornet wrote:
In the first initDialog of the program...
You have more than one?
theFrenchHornet wrote:
There is an edit box for the user to enter a value. It is declared as:
double m_newBP;
The variable associated with the edit control should be CEdit .
theFrenchHornet wrote:
void CModeCtrlDlg::OnBnClickedChangeBP ()
{
CGetNewBP getNewBP = new CGetNewBP;
INT_PTR nResponse = getNewBP.DoModal();
delete getNewBP;
m_currentBP = currentBP; <- error message that m_currentBP cannot be evaluated
UpdateData(false);
}
Several things wrong here. First, don't use a heap-based variable unnecessarily. Second, UpdateData() is also unnecessary. Third, too many variable involved. Fourth, getNewBP is not a pointer so the new operator cannot be used. Try something like this instead:
class CGetNewBP : public CDialog
{
public:
CEdit m_edit;
double m_BP;
};
void CGetNewBP::OnOK()
{
CString str;
m_edit.GetWindowText(str);
m_BP = atof(str);
}
...
class CModeCtrlDlg : public CDialog
{
public:
CEdit m_editBP;
};
...
void CModeCtrlDlg::OnBnClickedChangeBP()
{
CGetNewBP dlg;
INT_PTR nResponse = dlg.DoModal();
if (IDOK == nResponse)
{
CString str;
str.Format("%f", dlg.m_BP);
m_editBP.SetWindowText(str);
}
} Make sense?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes - makes sense.
Thanks so much for the quick reply - big help - I learned - have implemented and works.
|
|
|
|
|