|
Disregard post. I figured it out.
Steve Welborn
"Science can purify religion from error and superstition.
Religion can purify science from idolatry and false absolutes"
- 1987 John Paul the Great
|
|
|
|
|
Hi every body!
First, thank for your help.
I want to build an engine to read HTML Help file (.chm).
It can return topic, content, ... in the .chm file.
I was tried do that with API function HtmlHelp(...) (I found this function in HTML WorkShop), but it only return me the Help View with the .chm file, not any topic, content!
I really need this, please help me
Thanks!
|
|
|
|
|
SHALOM
everybody
I have a big problem,
Im using sockets to communicate 2 aplicattions,
Im using the functions send() and recv()
and everythings is going well ,,
but now I need to send a file , is a .Wav file
so the first thing I need to know is the size of the file to transfer first the size of the file , then in the other side of the connection I will know how size to receive.
well the size I get using this
FILE* f;
f=fopen("file1.Wav","rb");
int size;
fseek(f,0,SEEK_END); //move the pointer to the final of the file
size=ftell(f); //to know where is the pointer
rewind(f); //to put the pointer in the begining of the file
so I have in size the size of the file.
but this is an int var
Im trying to send the data like this
send(socket, &size, sizeof(size), 0);
so when I try to send it by the sockets it say
error C2664 cannot convert parameter 2 from int * to const char *
the function send() takes 4 param
http://msdn.microsoft.com/library/en-us/winsock/winsock/send_2.asp[^]
so,, can somebody tell me how to send the size of the file ???
Thanx
GOD BLESS YA
REU
|
|
|
|
|
REU wrote: int size;
fseek(f,0,SEEK_END); //move the pointer to the final of the file
size=ftell(f); //to know where is the pointer
rewind(f); //to put the pointer in the begining of the file
so I have in size the size of the file.
but this is an int var
Im trying to send the data like this
send(socket, &size, sizeof(size), 0);
Hello Reu,
please modify your code something like this :-
On Sender End
char szSize[10];
itoa(size,szSize,10);
send(socket, szSize, strlen(szSize),0);
On Receiver End
int iSize;
recv(socket, szSize, strlen(szSize),0);
iSize=atoi(szSize);
"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
|
|
|
|
|
maybe just like that:
send( socket, (const char*)&size, sizeof( int ), 0 );
|
|
|
|
|
You have posted to wrong person... Right person in above me
"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
|
|
|
|
|
I've got an application where I want a modeless dialog to stay on top of other applications.
When I call SetWindowPos for the main window, this window stays on top of the others but when I try the same code for the modeless it just stay on top of its parent.
The code is just basic SetWindowPos:
SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, HWND_TOPMOST);
Is there a trick or a way to make that modeless topmost ? or is it a problem from my program ?
Yarp
http://www.senosoft.com/
|
|
|
|
|
Just a guess, but you need to make the parent of your modeless dialog be the desktop, rather
than your main window. You can se the *owner* of your dialog to be your main window...
Iain.
|
|
|
|
|
Sure, this is a good idea. If I can't find a clean solution I will try this. Doesn't mean your solution is a dirty one, just looking for the perfect one if any
Yarp
http://www.senosoft.com/
|
|
|
|
|
Try SetForegroundWindow
--
======
Arman
|
|
|
|
|
yarp wrote: The code is just basic SetWindowPos:
SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, HWND_TOPMOST);
Is there a trick or a way to make that modeless topmost ?
Try this instead.
SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE);
CWnd::SetWindowPos[^]
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
I found a solution as suggested by Iain. The other ways din't work:
Here's the function that makes it :
void CfrmImg::EnableStayOnTop(bool bDesktop)<br />
{<br />
if (bDesktop) {<br />
::SetWindowLongPtr(m_hWnd, GWL_HWNDPARENT, NULL);<br />
::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0,<br />
SWP_NOMOVE | SWP_NOSIZE);<br />
}<br />
else {<br />
if (::GetParent(m_hWnd)==NULL)<br />
::SetWindowLongPtr(m_hWnd, GWL_HWNDPARENT, (LONG_PTR)frmMain->m_hWnd);<br />
::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0,<br />
SWP_NOMOVE | SWP_NOSIZE);<br />
}<br />
}<br />
I recall this is for a modeless dialog - don't know if it makes sense for modals.
The SetWindowLongPtr with GWL_HWNDPARENT parameter is a dirty hack. MSDN says SetParent should be used instead, but with SetParent it didn't work (I presume I have to change the windows style as suggested by MSDN - this is a later clean up work).
At the moment I'm happy with my stay on top function.
Thanks all for your assistance.
Yarp
http://www.senosoft.com/
|
|
|
|
|
I created a dialog class CSchDlg derived from CDialog. The dialog box has a few buttons(radio and checkboxes also) and a list box. Using the class wizard i created member variables of type CButton for all the buttons and of type CListBox for the list box.
Inside the OnInitDialog() i tried the following.
Say m_ctrlButton1 is of type CButton and is the member variable for the radio button with the ID IDC_RADIOBUTTON1
<br />
m_ctrButton1.SetCheck(BST_CHECKED);<br />
The above stmt produced error.
So i changed it to
<br />
CButton *pButton;<br />
pButton = (CButton *) this->GetDlgItem(IDC_RADIOBUTTON1);<br />
pButton->SetCheck(BST_CHECKED);<br />
... and it worked fine.
I tried the same thing for the ListBox also.
<br />
CListBox *pListBox;<br />
pListBox = (CListBox*) this->GetDlgItem(IDC_LISTBOX1);<br />
... but it produced Access Violation Error
What could be the reason?
Why do i have to use GetDlgItem() to set/enable or do anything on the buttons inside the OnInitDlg() but neednt do it in other functions?
|
|
|
|
|
nripun wrote: The above stmt produced error.
What error?
nripun wrote: CButton *pButton;
pButton = (CButton *) this->GetDlgItem(IDC_RADIOBUTTON1);
pButton->SetCheck(BST_CHECKED);
... and it worked fine.
Perhaps it only appeared to work?
nripun wrote: ... but it produced Access Violation Error
Are you trying to do this before CDialog::OnInitDialog() is called?
nripun wrote: Why do i have to use GetDlgItem() to set/enable or do anything on the buttons inside the OnInitDlg() but neednt do it in other functions?
You don't. GetDlgItem() is rarely, if ever, needed.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
Using it and needing it are two different things.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
DavidCrow wrote: What error?
Debug Assertion Error
File:afxwin2.inl
Line 590
DavidCrow wrote: Are you trying to do this before CDialog::OnInitDialog() is called?
I have tried both, b4 and after
I am restating my problem and i will try to be as clear as possible.
Aim is to have the dialog box pop up with a few checkboxes and radiobuttons checked and the listbox be filled.
Using class wizard i assigned the following member variables to the radiobuttons and the list box.
The first radiobutton is IDC_RADIOBUTTON1
The second radiobutton is IDC_RADIOBUTTON2
The listbox is IDC_LISTBOX1
When i open the MemberVariables tab in the ClassWizard i get the following..
ControlIDs Type Member
IDC_RADIOBUTTON1 CButton m_radio1
IDC_RADIOBUTTON1 CButton m_radio2
IDC_LISTBOX1 CListBox m_listbox1
Now when the dialog opens i want hte first radiobutton to be checked, the second radiobutton be disabled and the listbox be filled with certain text.
To achieve the above result i wrote the following code inside the OnInitDialog function.
<br />
m_radio1.SetCheck(BST_CHECKED);<br />
m_radio2.EnableWindow(FALSE);<br />
m_listbox1.AddString(BUFF);<br />
The above code gave the Debug Assertion Error i mentioned in the beginning of the post.
Now i change the above piece of code to
<br />
CButton *pButton;<br />
pButton=(CButton*)this->GetDlgItem(IDC_RADIOBUTTON1);<br />
pButton->SetCheck(BST_CHECKED);<br />
pButton=(CButton*)this->GetDlgItem(IDC_RADIOBUTTON2);<br />
pButton->EnableWindow(FALSE);<br />
..... it actually worked
Then i added the GetDlgItem for te list box
<br />
BOOL CSchDlg::OnInitDialog(){<br />
CDialog::OnInitDialog();<br />
CButton *pButton;<br />
CListBox *pListBox;<br />
pButton=(CButton*)this->GetDlgItem(IDC_RADIOBUTTON1);<br />
pButton->SetCheck(BST_CHECKED);<br />
pButton=(CButton*)this->GetDlgItem(IDC_RADIOBUTTON2);<br />
pButton->EnableWindow(FALSE);<br />
pListBox = (CListBox *)this->GetDlgItem(IDC_TIMETABLELIST);<br />
pListBox->AddString("Hope this works");<br />
<br />
The DoModal() of the Dialog box is done from another class CMySch.
The above piece of code works fine when i DoModal() for the first time.
But after i close the dialog and then again call DoModal from CMySch the following error:
Access violation
comes at pListBox = (CListBox *)this->GetDlgItem(IDC_TIMETABLELIST);
Inside the debug window the following was displayed
Name Value
---- ------
this {SchDlg 0x20383738 hWnd=???}
Hope things are clear
-- modified at 11:22 Tuesday 18th October, 2005
|
|
|
|
|
nripun wrote: the Debug Assertion Error i mentioned
Which line of code is actually asserting ? Can you post the code (meaning the block containing the ASSERT(), not your line of code) ?
nripun wrote: ..... it actually worked
Here I have to second DAvid : It seems to have worked, most surely this will not survive the release version.
You need to do all this at least inside OnInitDialog, or after it has been called, otherwise the controls do not exist as such (which explains the hWnd = ??) you mentioned.
~RaGE();
|
|
|
|
|
Sorry guys, My Mistake.
Before the line ,
pListBox = (CListBox*) this->GetDlgItem(IDC_LISTBOX1);
there was a sprintf() function which was not successful .
I corrected the sprintf() and now the code works fine. The mistake in the sprintf() caused the hWnd=???
Thank you all..
|
|
|
|
|
OK, afxwin2.inl, line 590
_AFXWIN_INLINE void CButton::SetCheck(int nCheck)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, BM_SETCHECK, nCheck, 0); }
meaning your control has not been initialized yet. You are calling this function too early (the handle m_hWnd has not been assigned yet).
~RaGE();
|
|
|
|
|
nripun wrote: Debug Assertion Error
File:afxwin2.inl
Line 590
Which indicates that the (control) window does not yet exist.
What does the dialog's DoDataExchange() and BEGIN_MESSAGE_MAP() methods look like?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
How can i change time on my computer with c++ ofcorse
|
|
|
|
|
There is function in Windows API called SetSystemTime(). You can find an example in MSDN.
|
|
|
|
|
Use the function
---SetSystemTime()----
Just search the MSDN u get the details
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|