|
The article I was reading was adding handlers for messages starting with = via the classwizard. One selects the class of the control and then handles the = message. Since I added my button through CW I dont have a control class for it in my CW. Thats why I incorrectly deduced that standard controls couldnt refelect.
Thanks,
ns
|
|
|
|
|
Hi All !
One problem pursues me for a few years already:
all my Win32 apps, written in VC++ (5.0-6.0),
crash on the second run under debugger.
Toolbar code in comctl32.dll causes access violation.
In more details:
1)The crap arises only when the app
is run 2 times successively from the VC++ IDE.
When running my app standalone, all's ok.
2)The program crashes when a mouse is moved
over the toolbar. WM_MOUSEMOVE is finally
dispatched to DefWindowProc() in comctl32.dll,
and there fails.
The mouse coordinates seem to be correct.
3)If toolbar is hidden, it's allright.
4)This bug seems to be not accidental
concatenation of circumstances:
this happened on different Windows versions,
under both VC5 and VC6, after many reinstallations
of the VC++ and OS etc,
and, finally, with all my Win32 GUI apps -
independently of tyhe architecture of the app,
and of the way I use tollbars
(containing ReBar, different styles, etc.)
5) The bug arises and disappears from time to time,
during the course of program development.
It seems that it depends somehow
on the size of the .exe or something like that.
Anyone ever faced this problem ?
Any help or hint would be appreciated !
Thanks in advance !
|
|
|
|
|
I was wondering what are the principles of creating a plugin extendable program.
I mean a program that accepts custom functions being created by third party developer, following certain rules.
Like Winamp, or Windows Media Player, that with plus has the Speaker Enanchement pluging: you install the plugin and there is a new Item in the Windows Media menu.
Is there any tutorial, guide, etc about this?
Thank you.
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
|
for the plugin system i use, i simply came up with a COM interface for the plugins and just told people that if they want to write a plugin for my apps they must: create an ATL object with this interface, name the object thusly, and place it in this folder.
at runtime, my app scans that folder and finds all the DLLs there. then it does a CreateObject call on each of "%DLLNAME.MyInterfaceName" . if that works, the object is a plugin.
it works great.
i can elaborate, if you'd like
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Chris Losinger wrote:
for the plugin system i use, i simply came up with a COM interface for the plugins and just told people that if they want to write a plugin for my apps they must: create an ATL object with this interface, name the object thusly, and place it in this folder.
Oh, this sounds very efficient.
Can you indicate me to some documentation about COM interfaces, since I am profane?
Thank You.
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
COM is a huge subject. but, here is a link to a tutorial i wrote on how to create plugins for my apps. you can use VC's ATL wizard to do most of the work.
to use these plugins, you need to create a COleDispatchDriver object and use it to create an instance of the plugin:
cosnt char * pInterfaceName = "TNImgAutomation";
CString csPluginObjectName = csDLLName + pInterfaceName;
COleDispatchDriver disp;
BOOL ok = disp.CreateDispatch(csPluginObjectName);
now we have a plugin object. the next part is to call methods of the plugin. this is where it gets tricky, in my system. because i create COleDispatchDriver objects directly, I am responsible for finding the methods and handling all of the method parameters myself.
Here's how you get the DISPID of a method in an ActiveX object (DISPID is basically the enumerated ID of the method. each method will have a unique ID).
HRESULT GetDispID(COleDispatchDriver &disp, const char *pName, DISPID &dispid)
{
USES_CONVERSION;
LPOLESTR lpOleStr = T2OLE(pName);
if (disp.m_lpDispatch==NULL)
{
ASSERT(0);
return E_INVALIDARG;
}
return disp.m_lpDispatch->GetIDsOfNames(IID_NULL, &lpOleStr, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
}
so you can do this:
DISPID dispid;
GetDispID(disp, "GetPluginName", dispid);
now you know the ID of that method. now you can call it.
here's how I call "GetPluginName" on a plugin:
CString CTNPlugInBase::GetPluginName()
{
CString csOut;
BSTR bsTemp;
long result;
static BYTE parms[] =
VTS_PBSTR;
disp.InvokeHelper(m_GetPluginNamesDispID, DISPATCH_METHOD, VT_I4, (void*)&result, parms, &bsTemp);
csOut = bsTemp;
SysFreeString(bsTemp);
return csOut;
}
the tricky part here is that "parms" variable. that's where you list the parameters for the method. with one parameter (in this case a pointer to a BSTR: &bsTemp), it's pretty easy. but when you get more parameters, it looks like this:
long result;
static BYTE parms[] =
VTS_PI4 VTS_PI4 VTS_PI4 VTS_I4 ;
disp.InvokeHelper(dispId, DISPATCH_METHOD, VT_I4, (void*)&result, parms, MemoryHandle, Width, Height, Context);
notice that there are no commas between those VTS_ things.
this might seem really horribly complicated if you've never used COM/ATL before. but it's really not too bad, once you get into it.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
I have to realize a very complicated user interface and
I have to insert a lots of control in a small space.
I'd like to used CDialog and CDialogBar classes but I need
to modify the window appearance in order to resize or remove
the window border and the title bar.
How can I do that???
Where can I find some samples ??
Thank you very much.
|
|
|
|
|
no sample is needed.
in resource, change dialog style to 'sizeable', that is all.
includeh10
|
|
|
|
|
I want to print data in text file out to the paper
If my data in text file is
110011110
I want to change 1 in the above data to solid black (which have 2 pixel width and 4 pixel height) and 0 in the above data to solid white (which have 2 pixel width and 4 pixel height)
This below is code but it does not work. The printer print the blank page. What wrong with my code?
code:
------------------------------------------------------------
void CTestprint::OnPrintButton()
{
DOCINFO di ;
CPrintInfo printInfo ;
CDC dc ;
CRect draw_area ;
CPrintDialog dlg(FALSE) ;
if (dlg.DoModal() == IDCANCEL)
return ;
HDC hDC = dlg.GetPrinterDC() ;
if (hDC == NULL)
return ;
di.cbSize = sizeof(DOCINFO) ;
di.lpszDocName = "Document name";
di.lpszOutput = NULL ;
// prepare the print information structure
dc.Attach(hDC) ;
printInfo.m_bDirect = TRUE ;
printInfo.m_rectDraw.left = 0 ;
printInfo.m_rectDraw.right = dc.GetDeviceCaps(HORZRES) ;
printInfo.m_rectDraw.top = 0 ;
printInfo.m_rectDraw.bottom = dc.GetDeviceCaps(VERTRES) ;
draw_area = printInfo.m_rectDraw ;
dc.StartDoc(&di) ;
CString testline = "101101001" ;
int x = 0 ;
int y = 0 ;
int pos = 0 ;
// start printing the document
dc.StartPage() ;
while (pos < testline.GetLength())
{
if ((testline.GetAt(pos)) == '1')
{
CBrush brush;
// Creation of the brush with a black color
brush.CreateSolidBrush(RGB(0, 0, 0));
// Create a rectangle with coordinates x,y,x+2,y+4 corresponding with top, left, bottom, right
CRect Rectangle(x, y, x + 2, y + 4) ;
// Fill a rectangle in the current device context or DC
dc.FillRect(&Rectangle , &brush);
x += 2;
}
else if ((testline.GetAt(pos)) == '0'){
x += 2 ;
}
pos++ ;
}
y += 4 ;
x = 0 ;
pos = 0 ;
dc.EndPage() ;
printInfo.m_rectDraw = draw_area ;
dc.EndDoc() ;
VERIFY(dc.DeleteDC()) ;
}
------------------------------------------------------------
|
|
|
|
|
Perhaps a little SetClipRect ?
|
|
|
|
|
Hi
I would like a source code -Format C++,that convert wave to mp3.
where am i can get it?
thanks;)
|
|
|
|
|
try http://www.mp3dev.org/mp3/[^]
Of course, mp3 encoding is a very complex process, and most free mp3 encoders are much less efficient than commercial versions.
You're probably better off just getting a command line mp3 encoder, and calling that from your program, rather than trying to include mp3 encoding directly
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Thanks for the help.
But how i'm doing what you mean?
|
|
|
|
|
Well basically you've got 2 choices of how to go about it
1) Include the mp3 encoder source into your application, and call it directly within your code. This could be very messy as the encoder is fairly large
2) Just distribute an encoder .exe with your app, and ShellExecute it to make it do the encoding
I think there's a dll version of LAME too, so that might be better
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Some MultiTrack recorders that I used when I were a musician can convert the final Work in MP3.
In the Properties Window there is a section where you browse for the MP3 encoder, and with it, the program encodes to MP3.
N-Track, used BladeEncoder, that's available as a DLL or as an EXE, I think.
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
You can find a lot of MP3 resources at www.mpeg.org
|
|
|
|
|
Hi,
I finally made my NT service start properly after Windows startup. But I have following problem: the service has window, so not console service. But, when the window appears after having been started as a service (using SrvAny tool), the graphics is very strange. Toolbar, status bar, list box columns headers, this all is somewhat "foxed", it seems like the GUI wasnt painted correctly after start. When I launch the program normally (not as a service), the GUI is normal. Does anybody know ?
Thanks Standa.
Celebrate Mr. Cesilko!
|
|
|
|
|
Actually this seems not to be a C++ question...
The usual reason for this problem is, that the service has not enough access rights to the window station/desktop. (Windowstations and desktops are securable objects like files. They contain a DACL that regulates which users are allowed to create windows, menus etc.)
I don't know if SrvAny handles this problem in any way. But general speaking only the currently logged in user and SYSTEM has proper access to WinSta0\Default. If your service runs under another account you may have to patch the DACLs.
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
Hi,
Is it possible to get a list of all menu shortcuts (NOT the ones in accelerator table)that an SDI application already uses? E.g: Alt+F invokes the file menu (In resource editor, we give an "&" prefix sothat the 'F' in a "File", will have an underline).
I need to give a short cut key dialog, where the user can set his own shortcuts to invoke certain functionalities of the application, but i need to check if it is already taken.
Thankx
Dave
|
|
|
|
|
You'll have to iterate over menu - use GetMenuItemCount and GetMenuString. For each item, find the & prefix. Following letter is the Alt-something you're after. Note that two ampersands are just displayed as one in menu item.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
The event is captured in the CListCtrl derived class
void CListCtrlEx::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;
...
}
But not in the class who uses the derived CListCtrlEx class.
// Header
...
//{{AFX_DATA(CPropDriver)
enum { IDD = IDD_DRIVERDIALOG };
CListCtrlEx m_Drivers;
...
void CSomeViewWithAListControl::OnItemchangedDriversList(NMHDR* pNMHDR, LRESULT* pResult)
{
...
}
How should I solve this ?
Greetings,
Niko
|
|
|
|
|
I guess that MFC first tries to dispatch the message to CListCtrlEx class via message reflection. Since there's a handler for LVN_ITEMCHANGED, function in CSomeView isn't called, because message was handled.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Thank you for your respond.
Do you know how to change this flow ?
If the message is captured by CSomeView, I could call ClistViewEx::OnItemchanged from there...
|
|
|
|
|
Your first chance to process LVN_ITEMCHANGED and other notifications sent through WM_NOTIFY message is virtual function CWnd::OnNotify. Override this in CYourView, check if notify code is LVN_ITEMCHANGED and control id corresponds to your list view. If this is the case, do whatever you need (including calls to CListCtrlEx's handler) and return TRUE.
Otherwise, just call CView::OnNotify to enable message map processing.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|