|
Help!
I am very confused with these functions :
OnWndMsg()
OnCommand()
OnCmdMsg()
What On earth are these functions's useful to out program?
And CView,CDocument,CMainFrame have their's own copy respectively
What's the difference to them?
Your answer will be greatly appreciated? I am very in urgence!
DavidWu
|
|
|
|
|
OnWndProc() is called by WindowProc during message reflection.
OnCommand() is called by the framework when the user selects an item from a menu, when a child control sends a notification message, or when an accelerator keystroke is translated. It processes the message map for control notification and ON_COMMAND entries, and calls the appropriate member function.
OnCmdMsg() is called by the framework to route and dispatch command messages and to handle the update of command user-interface objects. This is the main implementation routine of the framework command architecture.
|
|
|
|
|
Can anybody see why this doesn't link? (VSC++v.6)Any help would be truly appreciated...
HEADER FILE:
-----------
// set.h
#ifndef _INTLIST_H
#define _INTLIST_H
#include <iostream>
#include <vector>
#include <cassert> // for assert fn.
using namespace std;
template <class eltype="">
class Set
{
public:
// constructor
Set(); // construct a list of length 0
// accessors
int length () const;
// return length of list
Eltype retrieve (int i) const;
// retrieve ith list element
// (first element is in position 1)
bool contains (Eltype elt) const;
// return true if list contains elt; else false.
void make_empty();
// modifiers
void add (Eltype elt);
// add elt to end of list
void sort ();
// sort list in increasing order
void display ();
// display list on ostream os
Set<eltype> operator+(Set<eltype> set2);
void position(Eltype element, vector<int>& p);
void remove(Eltype element);
int len; vector<eltype> Elts;
private:
// length of the list
// elements of the list
bool sorted; // true if list is sorted; false otherwise
}; // end Int_list class declaration
template <class eltype="">
Set<eltype>::Set()
: len(0), sorted(true) // initializer list
{ }
template <class eltype="">
void Set<eltype>::add (Eltype elt)
{
if (len >= Elts.size())
Elts.resize(Elts.size() + 8);
Elts[len] = elt;
len++;
sorted = sorted &&
(len==1 || elt >= Elts[len-2]);
sort();
}
template <class eltype="">
void Set<eltype>::make_empty()
{
set();
Elts.resize(0);
}
template <class eltype="">
int Set<eltype>::length() const
{ return len; }
template <class eltype="">
void Set<eltype>::display()
{
ostream os=cout;
if (length()==0) return;
os << Elts[0];
for (int i=1; i<length(); i++)
="" os="" <<="" '="" elts[i];
}
template="" <class="" eltype="">
Eltype Set<eltype>::retrieve (int i) const
{
assert (0 <= i && i < len);
return Elts[i];
}
template <class eltype="">
bool Set<eltype>::contains (Eltype elt) const
{
for (int i=0; i< length(); i++)
if (Elts[i]==elt)
return true;
return false;
}
template <class eltype="">
void Set<eltype>::sort()
{
if (sorted) return;
int ins_elt; // element to insert
int ssv_sz; // sorted subvector size
int i;
for (ssv_sz = 1; ssv_sz < length(); ssv_sz++)
{
ins_elt = Elts[ssv_sz];
for (i = ssv_sz-1; i>=0; i--)
{
if (ins_elt >= Elts[i])
break;
Elts[i+1] = Elts[i];
}
Elts[i+1] = ins_elt;
}
sorted = true;
}
template <class eltype="">
void Set<eltype>::position(Eltype element, vector<int>& p)
{
int j=0;
for(int i=0;i<len;i++)
{
="" if(element="=Elts[i]){
" p[j]="i;
" j++;}
="" }
}
template="" <class="" eltype="">
void Set<eltype>::remove(Eltype element)
{
for(int i=0;i<len;i++)
{
="" if(element="=Elts[i]){
" for(int="" j="i;j<(len-1);j++)
" elts[j]="Elts[j+1];
" elts[j+1]="0;
" len="len-1;
" i="i-1;}
" }
}
template="" <class="" eltype="">
Set<eltype> operator+(Set<eltype> set2)
{
Set<eltype> result;
int total_length=len+set2.length();
result.Elts.resize(total_length);
for(int i=0;i<len;i++)
{
="" result.elts[i]="Elts[i];
" }
="" for(int="" j="len;j<set2.length();j++)
" return="" result;
}
#endif
test="" file:
---------
="" tstlist0.cpp
#include="" <iostream="">
#include <vector>
#include "ordintlist.h"
using namespace std;
template <class eltype="">
ostream& operator<<(ostream& outs, Set<eltype>& set2);
int main()
{
vector<int> p(6);
Set<int> L;
Set<int> M;
Set<int> N;
cout << "L= ";
L.display(); cout << endl;
cout << L.length() << endl;
L.add(30);
L.add(25);
L.add(30);
L.add(99);
M.add(67);
M.add(58);
M.add(30);
M.add(99);
cout << "L= ";
L.display();
cout << endl;
M.display();
cout << L + M;
cout << endl;
cout << N;
/*cout << L.length() << endl;
L.remove(30);
L.position(25, p);
cout << p[0];*/
cout << endl;
return 0;
}
// overloaded operators
template <class eltype="">
ostream& operator<<(ostream& outs, Set<eltype>& set2)
{
cout << "{";
for(int i=0;i<set2.len;i++)
{
="" cout="" <<set2.elts[i];
="" if(i!="set2.len-1)
" <<",="" ";
="" }
="" <<="" "}";
="" return="" cout;
}
errors:
------
compiling...
tstlist0.cpp
linking...
tstlist0.obj="" :="" error="" lnk2001:="" unresolved="" external="" symbol="" "public:="" class="" set<int=""> __thiscall Set<int>::operator+(class Set<int>)" (??H?$Set@H@@QAE?AV0@V0@@Z)
Debug/finally3.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
finally3.exe - 2 error(s), 0 warning(s)
|
|
|
|
|
yprog wrote:
Set operator+(Set set2)
I guess Set Set::operator+(Set set2) would be fine...
rechi
|
|
|
|
|
Hi,
I'm using MFC. I've have a handler for NM_CLICK for a listctrl, OnClickList() as shown below
ON_NOTIFY(NM_CLICK, IDC_ADDRESS_LIST, OnClickList)
OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
The OnClickList() contains code which executes when user clicks on a row in the listcontrol. The problem is that, I want execute the same function OnClickList() on some other event as well.
I have the item and subitem index of the listctrl, where I want to simulate click. I tried
::SendMessage api with WM_NOTIFY and NM_CLICK. But I'm not able send the click notification to the list ctrl.
Can somebody illustrate with some sample code on how to do this.
Thanks a lot
|
|
|
|
|
Instead of sending a message, just call the function onclicklist()...
Actually, you have pointed out a problem in your program structure. Nothing should be done in your onclicklist function but handle the pNMHDR to call another function, for example HandleMyItem(UINT nIndex, int nButton), so that you can call the HandleMyItem not only in onclicklist but also in other functions in your app, changing the parameters if necessary.
~RaGE();
|
|
|
|
|
Thanks for your reply.
I was able to solve my problem.
I was calling
SendMessage(WM_NOTIFY, NM_CLICK, (LPARAM)&NMListView);
instead of
<br />
CAddressPage* pAddressPage = (CAddressPage*) this->GetParent();<br />
pAddressPage->SendMessage(WM_NOTIFY, NM_CLICK, (LPARAM)&NMListView);
The Heinikin Uncertainty Principle: You can never be sure how many beers you had last night
|
|
|
|
|
Hi,
I'm using MFC. I've have a handler for NM_CLICK for a listctrl, OnClickList() as shown below
ON_NOTIFY(NM_CLICK, IDC_ADDRESS_LIST, OnClickList)
OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
The OnClickList() contains code which executes when user clicks on a row in the listcontrol. The problem is that, I want execute the same function OnClickList() on some other event as well.
I have the item and subitem index of the listctrl, where I want to simulate click. I tried
::SendMessage api with WM_NOTIFY and NM_CLICK. But I'm not able send the click notification to the list ctrl.
Can somebody illustrate with some sample code on how to do this.
Thanks a lot
|
|
|
|
|
Hello,
does anyone know some easy way (some library or function)
how to retrieve audio file information.
For example length (enough).
something like:
DWORD GetWaveLength(LPCTSTR lpszFile)
something to read this information from header.
It seems to be easy from file header,
but there is many kinds .. - not just PCM Wave format.
(extra header information - not only canonical format)
Does anyone know some library?
Thank you
viliam
|
|
|
|
|
Use AVIFileOpen to get informations about AVI and WAV formats .
For MP3 i thinkl theer is no particular library from mICROSOFT ..
for wma files use windows media format SDK ..
As an example ..
for AVI files ,
PAVIFILE pFile;
PAVIFILE* ppFile=&pFile;
long bResult;
AVIFILEINFO pFileInfo;
int height, width;
AVIFileInit();
str.Replace('\\','/');
//Opening the file
bResult=AVIFileOpen(ppFile,str,OF_READ ,NULL);
//read the strcuture
if (bResult==0)
{
AVIFileInfo(*ppFile,&pFileInfo,sizeof(pFileInfo));
}
AVIFileRelease(*ppFile);
the strcuture AVIFILEINFO will have the required details .The same code applies for WAV files also .....
Problem is external ,the soultion is internal for successs...the reverse is for failure
|
|
|
|
|
Iam doing a project in MFC using ODBC classes ..
1.I created a ODBC DSN for a access database mdb .WHile creating the DSN i did not specify any SYSTEM DATABASE .
2.When i executed the program ,it gave me an error "could not find "c:\cb\debug\dbo.db" .FIrst of all the access database i have given in DSN creation is different from that pointed out in the error message . Secondly the path shown in the ERROR message is the path of the executable .
How do i solve the problem .....
Every LIFE is unique and so there is no use in comparing ....
|
|
|
|
|
Hello, I've installed the msm files that allow me to use chinese and the international phoneme set...
I have done a little application that emulates the one that Microsoft gives as a sample, and the computer reads everything fine, but the problem is that I don't know how to make it read in any other language than english...
does anybody knows how to do it?
PS:
I'd like to read the international phonemes also, but I don't know how to do it... I read phonemes by adding <pron sym=" list_of_phonemes_separated_by_spaces"/>
as always thank you in advance...
|
|
|
|
|
Hy,
I am not familiar with different Windows technologies like MFC, COM, ATL...
I find a sample code with COM-s.
When I want to use MFC stuffs, like CStringArray, or dialogs, I have to
include some headers...
#include <afxcoll.h>
#include <afxwin.h>
After it the compiling working fine, but the linker has some errors, for
example:
Linking...
nafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in
SimpleDynProps.obj
nafxcw.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in
SimpleDynProps.obj; second definition ignored
Creating library Debug/ARXS_LX_OPM.lib and object Debug/ARXS_LX_OPM.exp
nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
nafxcw.lib(filelist.obj) : error LNK2001: unresolved external symbol
__mbctype
nafxcw.lib(timecore.obj) : error LNK2001: unresolved external symbol
__mbctype
nafxcw.lib(apphelp.obj) : error LNK2001: unresolved external symbol
__mbctype
What is the problem?
Can I use this technologies mixed?
Cheers,
Zoltan
|
|
|
|
|
Check that Project Settings|C/C++|Code Generation|Use Run Time Library matches the settings for the DLL's you are using.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
please help me how can i do !
first i create my new desktop, then open the window station with the name "winsta0", the next step SetProcessWindowStation and SetThreadDesktop are called, but when i call SetThreadDesktop an error occurs, the error number is 170 .
following is the function code(i call this function before showing the main window):
void CEnumDesktopApp::SetMyDesktop(void)
{
hDesktopCurrent = NULL;
hDesktopCurrent = GetThreadDesktop(GetCurrentThreadId());
hDeskDefault = NULL;
hDeskDefault = OpenDesktop("default", 0, FALSE,
DESKTOP_CREATEMENU |
DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE |
DESKTOP_HOOKCONTROL |
DESKTOP_JOURNALPLAYBACK |
DESKTOP_JOURNALRECORD |
DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP |
DESKTOP_WRITEOBJECTS);
if (hDeskDefault == NULL)
{
return ;
}
hDesktopLlx = NULL;
hDesktopLlx = OpenDesktop("llx", 0, FALSE,
DESKTOP_CREATEMENU |
DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE |
DESKTOP_HOOKCONTROL |
DESKTOP_JOURNALPLAYBACK |
DESKTOP_JOURNALRECORD |
DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP |
DESKTOP_WRITEOBJECTS);
if (hDesktopLlx == NULL)
{
SECURITY_ATTRIBUTES sa;
sa.bInheritHandle = TRUE;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
hDesktopLlx = CreateDesktop("llx", NULL, NULL, DF_ALLOWOTHERACCOUNTHOOK,
DESKTOP_CREATEMENU |
DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE |
DESKTOP_HOOKCONTROL |
DESKTOP_JOURNALPLAYBACK |
DESKTOP_JOURNALRECORD |
DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP |
DESKTOP_WRITEOBJECTS,
&sa);
if(hDesktopLlx == NULL)
{
AfxMessageBox("create desktop failed!");
return ;
}
}
HWINSTA hwinsta = NULL;
hwinsta = OpenWindowStation("winsta0", FALSE,
WINSTA_ACCESSCLIPBOARD |
WINSTA_ACCESSGLOBALATOMS |
WINSTA_CREATEDESKTOP |
WINSTA_ENUMDESKTOPS |
WINSTA_ENUMERATE |
WINSTA_EXITWINDOWS |
WINSTA_READATTRIBUTES |
WINSTA_READSCREEN |
WINSTA_WRITEATTRIBUTES);
if (hwinsta == NULL)
{
return ;
}
if (!SetProcessWindowStation(hwinsta))
{
return ;
}
if(!SetThreadDesktop(hDesktopLlx))
{
char szError[256] = {0};
ltoa( (long)(GetLastError()) , szError, 10);
AfxMessageBox(szError);
}
SwitchDesktop(hDesktopLlx);
}
|
|
|
|
|
I want to generate a struct variable whose fields are determined at the run time. It could be one with 2 fields or one with 2000 different fields.
For example,
During one execution the requirement could be-
struct
{
char[30] name;
int salary;
float age;
}
And during another execution it could be-
struct
{
double a[100];
float b;
long c[200];
int d;
char e;
}
I'll be very grateful if somebody could help me out.
Gaurav Gumber
|
|
|
|
|
You could use a union:
union my_union_t
{
struct
{
char[30] name;
int salary;
float age;
}
struct
{
double a[100];
float b;
long c[200];
int d;
char e;
}
};
you'd have to fill the union with all possible configurations, so it's not really at run time, but I'm not really sure that's possible.
|
|
|
|
|
The path goes to Project->Settings->Debug->Program arguments.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi.
I want to display the text of the previous selected tree-item.
I handle the tvn_selchanging message:
OnSelchangedTreeview(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
TV_ITEM tvItem;
tvItem = pNMTreeView->itemOld;
AfxMessageBox(tvItem.pszText);
*pResult = 0;
}
But this does not work, gives me all kinds of weird characters.
Anyone knows what the problem might be?
Greetings
Jens
|
|
|
|
|
I don't believe itemOld is valid at that point. You could just store the text in a member variable everytime a selection is made.
OnSelchangedTreeview(NMHDR* pNMHDR, LRESULT* pResult)
{
AfxMessageBox(m_strOldSel); // show old one
m_strOldSel = pNMTreeView->itemNew.pszText; // set it for next time
}
|
|
|
|
|
In my Application I got a lot of options that the user can customize the application with.
The problem I got is that when the option dialog is close I need to tell ALL windows that options have been changed so they can re-read them.
So is there a way to send a message that is received by ALL windows??
/Mathias
|
|
|
|
|
Yes, but make sure that ALL windows care about what is going to be sent to them before blindly sending a "global" message.
SendMessage(HWND_BROADCAST, ...);
|
|
|
|
|
Hi all,
does anybody know what the exact syntax is for sending a CString variable with SendMessage? I have tried every thing you can imagine:
UINT MyThread(LPVOID arg)
{
HWND hMain = (HWND) arg;
CString text;
text = "Hello";
SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM &) text);
}
LRESULT CMyDlg::OnSendHello(WPARAM wParam, LPARAM lParam)
{
CString* text = (CString *) lParam;
return 0;
}
What is wrong with this code?
|
|
|
|
|
Try correcting your SendMessage to this:
SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM) &text);
Maybe you need a LPCTSTR cast for &text, if it doesn't compile.
|
|
|
|
|
It appears you want to send a pointer to a CString.
Wrong:
SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM &) text);
Right:
SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM) &text);
Personly I recommend sending the address of the string instead of the address of a CString object.
SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM)(LPCSTR)text);
Trust in the code Luke. Yea right!
|
|
|
|
|