|
You might find WSAEventSelect interesting.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
Hi all,
I have an owner draw list ctrl.
i want to force a vertical scroll to be shown when the dialog
that the list sits on appears.
this is the code i've tried :
ListView_SetExtendedListViewStyle(m_lc.m_hWnd,
LVS_EX_FLATSB|LVS_EX_FULLROWSELECT );
now i've inserted some columns and then:
m_lc.ModifyStyle(0,WS_VSCROLL);
m_lc.SetScrollRange(SB_VERT,0,100);
m_lc.SetScrollPos(SB_VERT,0);
m_lc.ShowScrollBar(SB_VERT);
this doesn't show the vertical scroll bar.
the bar only show when the limit of inserted items succeeds.
can any1 show me what to do in order to force the scroll bar?
thanks in advanced
Yaron
Ask not what the application can do for you, ask what you can do for your application
|
|
|
|
|
Hello, I'm on the beg again
I'm trying to read in the header of a wav file. My code so far is..
<br />
struct<br />
{<br />
WORD wFormatTag;
WORD wChannels;
DWORD dwSamplesPerSec;
DWORD dwAvgBytesPerSec;
WORD wBlockAlign;
} FormatChunk;<br />
<br />
char ch[1];<br />
CFile waveFile;<br />
if(waveFile.Open(wavName,CFile::modeRead|CFile::typeBinary)==FALSE)<br />
{<br />
TRACE("Error opening file");<br />
return NULL;<br />
}<br />
<br />
while(1)<br />
{<br />
waveFile.Read(ch,1);<br />
TRACE("%c\n",ch[0]);<br />
if(ch[0] == 'E')<br />
break;<br />
}<br />
<br />
waveFile.Read(&FormatChunk,sizeof(FormatChunk));<br />
<br />
DWORD temp = FormatChunk.dwAvgBytesPerSec;<br />
TRACE("Sampling rate is : %ld\n",temp);<br />
TRACE("wChannels is : %0.2d\n",FormatChunk.wChannels);<br />
<br />
waveFile.Close();<br />
return temp;
Ignore the ugliness of it please My problem is reading in the wChannels value from byte offset 16, its a 2byte value. It should either be 0x10 or 0x20 in the file but I'm having problems reading it right. I've been playing with different variables to get it read right but all I get is either 16 for all of them or something like 8016
Or have I totally missed the point and theres an API function out there that'll do it for me? Thanks
|
|
|
|
|
Accoring to this[^] your FormatChunk structure is incorrect. It should be:
struct
{
DWORD wFormatTag; // Format category
DWORD dwFormatLen; // Length of format chunk - always 0x10
WORD wReserved; // Always 0x01
WORD wChannels; // Number of channels
DWORD dwSamplesPerSec; // Sampling rate
DWORD dwAvgBytesPerSec; // For buffer estimation
WORD wBytesPerSample;
WORD wBitsPerSample;
} FormatChunk;
Hope this helps,
Phil
|
|
|
|
|
Phil, thou art a god Knew it had to be something stupid that I was doing, thanks for that link too
/me gets out my winsocks books to see about your question
|
|
|
|
|
Hi ,
I am trying to access a property of an activex control and in
code statement
InvokeHelper() it pops up a message box telling its a runtime property.
how to avoid this??
waiting for ur replies eagerly.
pradeep
|
|
|
|
|
Suppose I have a database,which involves a table containing more than 10 thousand records.The structure of the table is:
table name: custom
collumn: custom_id,custom_name,custom_address
Now I should get all the records from the table by ODBC and show them in a Listview.
But a strange problem occurs:the listview only shows nearly 500 records,the others are blank except the custom_id.
It baffled me completely.Why the listview cannot show all the records?Does it have the limitation?If I limit the condition,just like"select * from custom where custom_id between 1 and 1000".I'm surprise to see the listview show the 1000 records.Which has problem,the listview or the databse?
Who can tell why?
Thank you for your kindness.
|
|
|
|
|
ListView should cope with more than 1000 records, although from a design point of view this is a bad idea.
Can you post some code as I suspect you have a bug somewhere.
Michael
"I've died for a living in the movies and tv.
But the hardest thing I'll ever do is watch my leading ladies,
Kiss some other guy while I'm bandaging my knee."
-- The Unknown Stuntman
|
|
|
|
|
Michael P Butler wrote:
although from a design point of view this is a bad idea.
Which is, of course, why there's an Owner Data style. It's non-trivial to hook up to a dynamic recordset, since there are issues with deleted records, but for simple selection it's fairly simple.
Steve S
One day, I'll have a good signature...
|
|
|
|
|
I have a class that subclass from CEdit .Now I want to subclass from this class.After I make generic class and subclass it from that class,after compiling I got many errors in my base class.Also I got an error that:
error C2504: 'CEdit' : base class undefined
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Make sure whether you include MFC header file
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
XSimon wrote:
MFC header
Could you name them please?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I declare this below data.
[code]
CArray<unsigned char,="" unsigned="" char=""> m_data1, m_data2, m_data3, m_data4;
[/code]
I want to to sort m_data1, m_data2, m_data3, m_data4.
If you know how to do that, please tell me.
Thank you very much.
|
|
|
|
|
I honestly don't know, but this is one major reason why you'd be better off to ditch CArray for std::vector. I have a number of articles here on CP with regard to the STL to get you started.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
CArray doesn't have a built-in Sort function. So you'd either have to write your own (using Quicksort and friends).
I'd suggest just scrapping the whole idea of using CArray (and MFC collections) and move onto std::vector and std::sort (i used to be an MFC junkie, but I've been converted to STL ).
|
|
|
|
|
Hello!
Since you already have gotten a couple of suggestion to use STL, I thought I give you what you asked for
Here on CodeProject there is a article about this!
Mr. Martin Ziacek has described how to use quicksort together with CArray.
http://www.codeproject.com/cpp/qarray.asp
Mike Eriksson
Sonork 100.21825
|
|
|
|
|
I have a class that base from anothrt one.I want its constructor be a base class constructor.How can I do it?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
|
Thanks
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Hello,
does anybody know how to get the unique LAN-ID from MFC C++?
I have to code a license control tool...
Thank you for answers!
Andreas Niedermeier
==----===
|
|
|
|
|
You can use the physical address of your net adapter
int CTcpCfg::GetMacAddress(LPMAC_ADDRESS pMacAddr)
{
NCB ncb;
UCHAR uRetCode;
int num = 0;
LANA_ENUM lana_enum;
memset(&ncb, 0, sizeof(ncb) );
ncb.ncb_command = NCBENUM;
ncb.ncb_buffer = (unsigned char *)&lana_enum;
ncb.ncb_length = sizeof(lana_enum);
//ÏòÍø¿¨·¢ËÍNCBENUMÃüÁî,ÒÔ»ñÈ¡µ±Ç°»úÆ÷µÄÍø¿¨ÐÅÏ¢,ÈçÓжàÉÙ¸öÍø¿¨
//ÿÕÅÍø¿¨µÄ±àºÅµÈ
uRetCode = Netbios(&ncb);
if (uRetCode == 0)
{
num = lana_enum.length;
//¶ÔÿһÕÅÍø¿¨,ÒÔÆäÍø¿¨±àºÅΪÊäÈë±àºÅ,»ñÈ¡ÆäMACµØÖ·
for (int i = 0; i < num; i++)
{
ASTAT Adapter;
if(GetAddressByIndex(lana_enum.lana[i],Adapter) == 0)
{
pMacAddr[i].b1 = Adapter.adapt.adapter_address[0];
pMacAddr[i].b2 = Adapter.adapt.adapter_address[1];
pMacAddr[i].b3 = Adapter.adapt.adapter_address[2];
pMacAddr[i].b4 = Adapter.adapt.adapter_address[3];
pMacAddr[i].b5 = Adapter.adapt.adapter_address[4];
pMacAddr[i].b6 = Adapter.adapt.adapter_address[5];
}
}
}
return num;
}
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Hello;
I'm in trouble with setitem method of CListCtrl. Actually, i have set the item value, but it has not get the correct value at following code part.
<br />
int n=0, idx=0;<br />
CString pbBuffer;<br />
char chngval;<br />
char hexval[2];<br />
char* out;<br />
out = (char*)malloc(sizeof(char) * 41);<br />
memset(out, 0x00000000, sizeof(char) * 41);<br />
<br />
while(m_cPeriodList.GetCount()!=idx)<br />
{<br />
m_cPeriodList.GetText(idx, pbBuffer);<br />
n=wcstol(pbBuffer, '\0', 10);<br />
memset(hexval, 0, sizeof(hexval));<br />
for (int i=1; i>=0; i--) {<br />
chngval="0123456789ABCDEF"[((n >> i*4) & 0xF)];<br />
memcpy(hexval+(1-i), &chngval, sizeof(char));<br />
}<br />
hexval[2]='\0';<br />
idx++;<br />
strcat(out, hexval);<br />
}<br />
<br />
int zerocounter=(40-(idx*2))/2;<br />
for(int temp_idx=0; zerocounter!=temp_idx; temp_idx++)<br />
strcat(out, "00");<br />
<br />
lvi->mask = LVIF_TEXT;<br />
lvi->iSubItem = 3;<br />
lvi->iItem = 0;<br />
lvi->pszText = (LPTSTR)(LPCTSTR)out;<br />
m_list->SetItem(lvi);<br />
szTemp.Empty();<br />
<br />
free(out);<br />
Everythings going fine until "lvi->pszText = (LPTSTR)(LPCTSTR)out;". At this statement, the out value has "B0B0B0B0", but lvi->pszText show own value like "?????????????". What does it mean?
Thank you
|
|
|
|
|
Why are you mixing C and C++ ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Just a sample for myself. Sorry.
|
|
|
|
|
I've changed my code to C++ and life is good now.
INT iHexIdx=0; // Hex convertion loop index
LONG lRowIdx=0; // Row index pointer
LONG lRowLongValue=0; // Converted row value
CString rTemp; // Temporary value
CString rString; // Listbox selected item text
// Loop until end of list
while(m_cPeriodList.GetCount()!=lRowIdx)
{
// Get text from listbox
m_cPeriodList.GetText(lRowIdx, rString);
// Convert CString listbox value to LONG
lRowLongValue = _wtoi(rString.GetBuffer(rString.GetLength()));
// Convert byte to hex
for(iHexIdx=1; iHexIdx>=0; iHexIdx--)
rTemp.Insert((rTemp.GetLength()+(1-iHexIdx)),("0123456789ABCDEF"[((lRowLongValue >> iHexIdx*4) & 0xF)]));
// Increase row index
lRowIdx++;
}
// Fill empty bytes with 0
for(iHexIdx=rTemp.GetLength(); iHexIdx<=40; iHexIdx++)
rTemp.Insert(iHexIdx, _T("0"));
// Set comment
lvi->mask = LVIF_TEXT;
lvi->iSubItem = 3;
lvi->iItem = 0;
lvi->pszText = (LPTSTR)(LPCTSTR)rTemp;
m_list->SetItem(lvi);
|
|
|
|