|
You use from CWnd and Cwnd doesnt need to parameter or if you want to use parameter in Cwnd see in MSDN:
CWnd::HtmlHelp
virtual void HtmlHelp(
DWORD_PTR dwData,
UINT nCmd = 0x000F
);
whitesky
|
|
|
|
|
it's not all key in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" has display icon property.so I can't get icon's infomation.could anyone help me!
thanks sincerely!!
pls forgive me poor english syntax.
|
|
|
|
|
i'm having a problem linking my library to the library using Visual C++ 6.0/MFC an someone help me?
i went to Project-> Settings, selected "Link" pane, entered the path of where the Library is under "Object/library modules:" (Settings For : All Configurations)... but i still cannot link them together why is tat so? pls help me
|
|
|
|
|
we3Guy wrote: i'm having a problem linking my library to the library using Visual C++ 6.0/MFC an someone help me?
you can directly link your libaray using pragma directive:-
i.e. #pragma comment(lib,"YOUR LIBARARY") in stdafx.h file!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi fellows. I have a CWnd-derived class that has two CStatic members, that are created dynamically.
My question is simple: How do I do in order to receive messages of such members?
Any suggestion will be appreciated.
Regards,
FG.
A polar bear is a bear whose coordinates has been changed in terms of sine and cosine.
|
|
|
|
|
If you're trying to handle notifications from them, you do it the same way you do other controls. Place an entry in the message map. The wizard won't do it for you, but you can do it manually.
Software Zen: delete this;
|
|
|
|
|
I already tried that, but didn't work...
Regards,
FG.
A polar bear is a bear whose coordinates has been changed in terms of sine and cosine.
|
|
|
|
|
One other thing: when you create the static controls, you need to make sure you specify the SS_NOTIFY style, which enables the STN_* notifications.
Software Zen: delete this;
|
|
|
|
|
Do you have two static with a class derived(CStatic)
whitesky
|
|
|
|
|
No, it is not derived:
<br />
CStatic m_lblArrowUp;<br />
CStatic m_lblArrowDown;<br />
<br />
<br />
m_lblArrowUp.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_BITMAP, rectUp, this, IDC_ARROWUP);<br />
m_lblArrowDown.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_BITMAP, rectDown, this, IDC_ARROWDOWN);<br />
m_lblArrowUp.SetBitmap(LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_VERTICLE_SCROLLBAR_UPARROW)));<br />
m_lblArrowDown.SetBitmap(LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_VERTICLE_SCROLLBAR_DOWNARROW)));<br />
I have a CWnd-derived class and I'm creating a custom control. This control needs vertical scrollbar, so I'm using two bitmaps, one as de up arrow and the
other as the down arrow. I already placed them, now I need to receive the notification (the click notification).
Regards,
FG.
A polar bear is a bear whose coordinates has been changed in terms of sine and cosine.
|
|
|
|
|
I am looking for a way to add a16 X 48 matrix of owner drawn buttons to a small
utility I am developing in VC++ 2005. Can anyone direct me to specific articles
or code to accomplish this task. I want to preserve 2d addressing. Initialization
might go like:
private: System::Windows::Forms::Button^ Mybutton[][];
Chris
|
|
|
|
|
|
While boldly trudging through my first foray into MFC multithreading I encountered a problem.
Setup: I have a simple dialog-based app that launches a worker thread at OnInitDialog(). The dialog has one button (w/ event handler) and one edit box for output.
I want the main thread/dialog to do the following after the button is clicked:
1) Output "Foo" to the edit box
2) Give a "go ahead" signal/event to the patiently waiting worker thread
3) Wait for the "I'm finished" signal/event from the worker thread
4) Output an updated global integer ("iCount_") to the same edit box
Meanwhile, I want the worker thread to:
1) Wait for the "go ahead" signal/event from the dialog
2) Do some generic calculation (e.g. increment a global integer) while the main thread waits
3) Pause for a short time (e.g. 1 second) while the main thread continues to wait
4) Signal the main thread that it can stop waiting
[See the code from my crappy implementation below]
The word "Foo" should be displayed and then replaced by the updated global after 1 second, but that's not what occurs in my implementation. After OnBnClicked() is called, the edit box remains static for 1 second (no "Foo") before the updated integer is correctly displayed. What am I missing?
Is something in the bowels of MFC toying with my ignorance? Is this a class issue? Am I violating the windows-multithread prime directive without knowing it?
Any insight would be greatly appreciated.
"MyDlg.cpp":
...
BOOL CMyDlg::OnInitDialog()
{
...
iCount_ = 0;
hEventBeginWork_ = CreateEvent(NULL, FALSE, FALSE, NULL);
hEventWorkDone_ = CreateEvent(NULL, FALSE, FALSE, NULL);
hEventSleep_ = CreateEvent(NULL, FALSE, FALSE, NULL);
AfxBeginThread(WorkerThread, this);
...
}
...
UINT CMyDlg::WorkerThread(LPVOID p)
{
CMyDlg *pDlg = (CMyDlg *) p;
pDlg->WorkerThreadLoop();
return 0;
}
void CMyDlg::WorkerThreadLoop()
{
while (1)
{
WaitForSingleObject(hEventBeginWork_, INFINITE);
iCount_++;
WaitForSingleObject(hEventSleep_, 1000);
SetEvent(hEventWorkDone_);
}
}
void CMyDlg::OnBnClicked()
{
CString szCount;
m_editCount.SetWindowText("Foo");
SetEvent(hEventBeginWork_);
WaitForSingleObject(hEventWorkDone_, INFINITE);
szCount.Format("%d", iCount_);
m_editCount.SetWindowText(szCount);
} "MyDlg.h":
class CMyDlg : public CDialog
{
public:
...
HANDLE hEventBeginWork_;
HANDLE hEventWorkDone_;
HANDLE hEventSleep_;
int iCount_;
static UINT WorkerThread(LPVOID);
void WorkerThreadLoop();
...
CEdit m_editCount;
afx_msg void OnBnClicked();
};
-- modified at 18:26 Thursday 6th July, 2006
|
|
|
|
|
In your CMyDlg::OnBnClicked handler, you're calling WaitForSingleObject(hEventWorkDone_, INFINITE); . This blocks the UI thread, which keeps it from handling messages, which keeps it from updating the screen (and a whole lot of other things).
Blocking the message pump Is A Bad Thing, and yes, you have violated the Windows prime directive: Thou Shalt Process Messages If Thee Wishes Thine UI To Behave Properly.
As a rule, a better approach to communication between a worker thread and a window (e.g. the UI thread) is to have the worker thread use PostMessage to send user-defined messages to the window.
Software Zen: delete this;
|
|
|
|
|
Gary R. Wheeler wrote: Thou Shalt Process Messages If Thee Wishes Thine UI To Behave Properly
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"
|
|
|
|
|
I suppose I was hoping that a window updated before the UI thread was blocked would display correctly.
*sigh* Anyway, thanks for the response, it was very helpful. PostMessage, here I come!
|
|
|
|
|
I'd like to display a few bitmaps as layers, something like in Adobe Photoshop. First to display one bitmap (layer), then alphablend next bitmap (layer) and then next, and next, and... To do this I prepered array of 32_bit_per_pixel bitmaps (with alpha channel): HBITMAP hBitmaps[10];.
Code looks like this:
BLENDFUNCTION m_blend;<br />
m_blend.BlendOp = AC_SRC_OVER;<br />
m_blend.BlendFlags = 0;<br />
m_blend.SourceConstantAlpha = 255;<br />
m_blend.AlphaFormat = AC_SRC_ALPHA;<br />
<br />
i = 0;<br />
while( i<n )<br />
{<br />
dcTmp.SelectObject( hBitmaps[i++] );<br />
<br />
AlphaBlend( dcLayout.m_hDC,<br />
x, y, uWidth, uHeight,<br />
dcTmp.m_hDC,<br />
0, 0, uWidth, uHeight, <br />
m_blend );<br />
}
Creating these bitmaps I'm using is OK. Alphablending is also working OK when bitmaps has alpha channel set to 255 for each pixel.
But there seem to be a problem, when bitmaps has transparent alpha channel. I also want to display transparent layer (later user will be able to draw on this layer). Each pixel in this transparent layer has alpha channel with value = 0 (so it's totaly transparent).
When this layer is filled with white color RGB(255,255,255) it isn't transparent, but when is filled with, for example, RGB(200,0,0) or RGB(0,0,0), then layer is transparent but not totaly, only in 80-90%! :/
I also see that: when layer is a photography or some picture pixels with alpha channel less then 255 are not partly transparent but partly white! :/
I dont't know what I may do wrong. Can you help me?
~~~~
|
|
|
|
|
Whats problem or What do yo need?
whitesky
|
|
|
|
|
Hi
We know if we allocate memory in stack we must give its size before.But in heap the size is not importatnt i know.We allocate it then we delete it.
But this code gives error at the runtime.(HEAP CORRUPTION DETECTED)
<br />
int main ()<br />
{<br />
char* mytext = new char[];<br />
cout << "Enter name";<br />
cin >> mytext;<br />
cout << mytext;<br />
delete[] mytext;<br />
return 0;<br />
}<br />
if i give size like char* mytext = new char[8]; it does not give error.
1-)So why do we need heap?I see that i can not allocate memory dynamicly.I must give size like stack allocation.
2-)Can you explain me please how i can fix error.
3-)I want to allocate memory dynamicly(unknown size until runtime) in heap with new.How can i do this?
I am looking for your answers.
Thanks..
-- modified at 17:08 Thursday 6th July, 2006
|
|
|
|
|
sawerr wrote: I want to allocate memory dynamicly(unknown size until runtime) in heap with new.How can i do this?
you can not allocate an unknown amount of memory. you must specify an amount when you do the allocation.
the easiest way to handle the problem is to use a string class (like std::string) that can handle the allocation for you, automatically:
#include < string >
...
std::string mytext;
cout << "Enter name";
cin >> mytext;
cout << mytext;
why do you new dynamic allocation? you need it so you can allocate memory that is larger than the size of the stack. you can also use it so that subroutines can allocate objects and variables whose number and/or size are unknown to the caller at compile-time.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Thanks Chris
I know string class.But i want to understand memory much more detail.
How can i do this allocation with a char pointer in heap.
Is there a way?CAn you please give me much details about heap allocation.Whay do we need it?Differences between stack.
Thanks again.
|
|
|
|
|
sawerr wrote: How can i do this allocation with a char pointer in heap.
i am not sure of how the string class handles this, but one way to do this is:
1. allocate 100 chars on the heap
2. read 100 chars from input into your buffer
3. re-allocate the buffer with another 100 chars
4. go to 2
stop when you reach the End Of File.
sawerr wrote: Whay do we need it?Differences between stack
you can't allocate as much memory on the stack as you can from the heap.
BYTE *p = new BYTE[1000000] will work.
BYTE p[1000000] will probably fail
Cleek | Image Toolkits | Thumbnail maker
-- modified at 18:09 Thursday 6th July, 2006
|
|
|
|
|
hmm ok i understand.
I have one more question.It is very important for me
In my first code at runtime debugger gives HEAP CORRUPTION DETECTED as i said
But for this code:
<br />
char* mytext = new char[]; <br />
mytext = "Enter name"; <br />
delete[] mytext; <br />
return 0;<br />
DEbug assertion Failed!
Expression : _BLOCK_TYPE_IS_VALID
What is the differences these errors?Here in compile time compiler can see the length:
"Enter name" is 11(with null).But still can not allcate it in heap and still gives error at runtime as i said.
Can you please explain this?
thanks for all help.
|
|
|
|
|
sawerr wrote: char* mytext = new char[];
i can't even get that statement to compile.
you absolutely need to specify a number of elements to allocate:
ex.
char* mytext = new char[100];
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
class RTI_EXPORT RTIambassador {<br />
public:<br />
#include "RTIambServices.hh"<br />
RTIambPrivateData* privateData;<br />
private:<br />
RTIambPrivateRefs* privateRefs;<br />
};
I didn't know the meaning of having two names beside the name Class like this:
class RTI_EXPORT RTIambassador
Someone gave me an answering saying the class is intended to be exported from a DLL.
What is meant by a class being exported from a DLL. Does this mean that this specific code here is a a little chunk of a code from a DLL file and is being used by the current file Im working with? Or does it mean, tell the DLL linker to add this specific class onto the linker as an addition function.
I'm very confused here. Someone help me out. Thanks in advance
Cheers,
Jay -
|
|
|
|