|
Also, what are the properties of your dialog resource?
Try setting the dialog's "Overlapped Window" property to true.
|
|
|
|
|
The setting the dialog's "Overlapped Window" property is changed to true,
but the result is the same.
g_pJoystick = 0x001672d4
hwndMain = 0x0007059c {unused=???}
hr = E_HANDLE
Please help!
|
|
|
|
|
Hmm something else is going wrong. The dialog doesn't have the WS_CHILD style does it?
Maybe a dialog is unacceptable as a "top-level window"?
Just for the heck of it, maybe try calling your InitDirectInput() from your dialog's WM_INITDIALOG
handler.
|
|
|
|
|
I have created the project again. Now it will not get the E_HANDLE.
The InitDirectInput(*this) coding is called from OnTimer as before.
It can detect the joystick, but it cannot get any data from the joystick.
The coding are
if(!FAILED(InitDirectInput(*this)))
{
if( NULL != g_pJoystick )
{
HRESULT hr;
TCHAR strText[512] = {0}; // Device state text
DIJOYSTATE2 js; // DInput joystick state
// Poll the device to read the current state
hr = g_pJoystick->Poll();
if(FAILED(hr) )
{
hr = g_pJoystick->Acquire();
while( hr == DIERR_INPUTLOST )
hr = g_pJoystick->Acquire();
}
if( !FAILED( hr = g_pJoystick->GetDeviceState( sizeof(DIJOYSTATE2), &js ) ) )
{
for( int i = 0; i < 128; i++ )
{
if ( js.rgbButtons[i] & 0x80 )
{
TCHAR sz[128];
StringCchPrintf( sz, 128, TEXT("%02d "), i );
StringCchCat( strText, 512, sz );
}
}
}
Please help!
|
|
|
|
|
I don't see anything except GetDeviceState() can return DIERR_INPUTLOST but Acquire() doesn't.
|
|
|
|
|
I found that the first Poll() get "Invalid". After the Acquire(), the hr is S_OK. Then if I Poll() it again, it will get a S_False. Why?
Please help!
|
|
|
|
|
LaHaHa wrote: I found that the first Poll() get "Invalid". After the Acquire(), the hr is S_OK. Then if I Poll() it again, it will get a S_False. Why?
Poll returns what? DI_OK, DI_NOEFFECT or error DIERR_INPUTLOST, DIERR_NOTACQUIRED, or
DIERR_NOTINITIALIZED?
You only need to acquire the device once right?
|
|
|
|
|
After I put the InitDirectInput(*this) in the OnInitDialog(), it is alright.
But my program need to check the joystick to be available periodically.
So how can I do it?
Please help!
|
|
|
|
|
check if it's available periodically or check for input?
Are you going to poll or use events and separate thread(s)?
p.s. sorry I'm replying to different messages - The site is not letting me reply sometimes
|
|
|
|
|
If the joystick is plugged at the beginning, it is alright. If not, the program cannot detect it.
I would like to make some response for the joystick button.
Could you give me more suggestion?
(Sorry for making trouble to you!;P Thank you for your help! )
|
|
|
|
|
LaHaHa wrote: I would like to make some response for the joystick button.
Could you give me more suggestion?
In the DirextX SDK see the following sections under DirectInput/Programming Guide/DirectInput Device Data:
Polling and Event Notification
Joystick Data
It's explained there better than I ever could
|
|
|
|
|
I think my problem is the initialization.
My program need to periodically do the initialization of joystick. Could you give me more suggestions?
Please help!
|
|
|
|
|
i am developing an mfc application for internet browsing centres. i have got a requirement. after booting my application window should be displayed and the user should not be able to interact with the system other than with my application.how can i acheive this?
|
|
|
|
|
i want to add a view to the client of a window
i do it by following code
BOOL CMainWindow::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
BOOL ret = m_wndSplitter.CreateStatic(this, 1, 1);
ret = ret | m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CTestView), CSize(100, 100), pContext);
return ret;
}
But it can get my goal. How can i do it?
Thank you~
just do it
|
|
|
|
|
Hello,
I have two document templates and through a menu option I want to open a new document of one document type through a menu option which is not File New option.How do I do it.
How to divert a message handler to CWinApp class instead of CView? ANd how do I pass parameters to CDocument class from CWinApp to initialize CDocument class.
Thanks
Prithaa.
|
|
|
|
|
When a web server sends a response that does not contain a Content-Length: header, and is not chunked, how is a application supposed to know when it has finished downloading the complete document?
The response headers give no clue how big the file is, so how does one know?
The web server is not closing the connection, BTW. So I need to avoid blocking.
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
Never mind, I found out how. When the document is done, the recv() function returns ZERO bytes received.
Thanks for reading my post!
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
Hey, guys.
My concert lighting app has been on the back burner for several years now. Having reached the point where I'm ready to start designing the lighting for my current show, I naturally found a few tweaks I wanted to make to the software. Tried to build it in VS 2003 and got a lot of whining about DAO being deprecated, and recalled that MFC is hard wired to DAO 3.5 (which the compiler also isn't liking). So, I guess I need to rewrite the db code. Not what I had in mind when I opened the lid on this thing.
This is a standalone MFC app talking to a local Access db, and since it involved realtime control of moving lights, performance is a consideration. The current code is using the CDatabase / CRecordset approach. Since Microsoft has kicked DAO to the curb, I'm wondering what db technology I should port this to. I absolutely do not want to drag the .NET framework into the app.
Is there a new set of database access classes that plays nice with Access that are non .NET? I'd appreciate any suggestions you guys might have as it's currently dead in the water.
By the way, looked at the ADO forum, but it seems to be mostly SQL related topics. What I need is help porting an app to whatever non .NET API is appropriate for MFC.
|
|
|
|
|
The ODBC classes are similar if not identical. If performance is an issue (it's unlikely ODBC is
noticeably faster or slower than DAO) then caching performance-critical data in RAM is the
way to go.
I'm curious (since I've been a musician forever) how are you interfacing to hardware?
Mark
|
|
|
|
|
Hey, Mark.
Thanks so much for the quick reply. Regarding the app, I'm controlling the lighting via the standard DMX protocol that concert lighting speaks. I'm using a printer port dongle (they have cat5 devices these days) from www.artisticlicence.com[^]for the DMX. The app also speaks MIDI and plays CD & wav audio via DirectX. Believe it or not, all this for bar band shows - 10,000 watts of mostly Martin lighting.
Now that you mention it, I poked around in the code (haven't been in this stuff for several years now), and see that there's both a CDaoDatabase & CDatabase. Hopefully, it'll just be a matter of some global search & replace stuff and a little bit of setup on an ODBC connection. Any gotchas that come to mind?
|
|
|
|
|
Sounds fun! A previous band I played with dragged lights around for a while. I always thought
it would be fun to do a PC interface for them but I never got around to it
Christopher Duncan wrote: Any gotchas that come to mind?
I've only used the ODBC (non-dao) classes but from what I understand they are very similar.
No gotchas I can think of except perhaps the database connection itself. Make sure you have a
later version of MDAC (there's all kinds of versions) and the latest ODBC driver for Access.
That will save any immediate trouble. VS2003 can generate CRecordset classes for all your tables
if you have a database to connect to. I imagine you could do that with DAO as well
I use these classes pretty much every day on VS2003 so if something comes up I'll try and help
out.
Mark
|
|
|
|
|
I used to do gigs hauling around a bunch of par cans, but these moving lights really up the bar on things. Of course, you just haven't lived until you've experienced a bug in your code while controlling a room full of these things. Quite exciting.
I took the quick & dirty approach and did a global replace of CDao to C, and that's getting me in the right direction. The two main obstacles I'm looking at presently are these.
First, I use CDaoRecordset::GetLastModifiedBookmark() all over town in the scenario where I'm adding a new record and then need to access the record I just added, e.g.
CWaitCursor ThinkWeBetterWaitTillTommorrow;<br />
try<br />
{<br />
FormatTextAndName();<br />
CDesignTimeEventSet setDesignTimeEvent;<br />
setDesignTimeEvent.Open();<br />
setDesignTimeEvent.AddNew();<br />
setDesignTimeEvent.m_lType = eImageEventPlayCd;<br />
setDesignTimeEvent.m_strName = m_strName;<br />
setDesignTimeEvent.m_strEventData = m_strEventData;<br />
setDesignTimeEvent.Update();<br />
setDesignTimeEvent.SetBookmark(setDesignTimeEvent.GetLastModifiedBookmark());<br />
m_lDesignTimeId = setDesignTimeEvent.m_lId;<br />
setDesignTimeEvent.Close();<br />
}<br />
catch(CException* pe)<br />
{<br />
pe->ReportError();<br />
pe->Delete();<br />
}
What's the preferred method of doing this when using CRecordset rather than CDaoRecordset (the former doesn't have this function)?
Secondly, I make significant use of CQueryDef to execute various query & non query operations, e.g.
CQueryDef defTruss(&g_dbCurrent);<br />
CString strQuery = "";<br />
strQuery.Format("DELETE * FROM PatternStep WHERE DesignTimePattern = %ld", m_lPatternId);<br />
defTruss.Create(NULL, strQuery);<br />
defTruss.Execute();<br />
defTruss.Close();
What class would you use in the CDatabase world?
Really appreciate the help, man.
|
|
|
|
|
For bookmarks, this link has the info: CRecordset::SetBookmark[^]
I've never heard of the CQueryDef class
I do direct queries through a CRecordset-derived class object (which represents a table).
There's a wizard to create these classes quickly from an existing database. The wizard-created
class has member variables for each column in the table, which are automagically filled with
the data for the current row as you scroll through result sets.
Something like:
pPatternStepTable = new CPatternStepTable(pDB);
...
CString strQuery = "";
strQuery.Format("DELETE * FROM PatternStep WHERE DesignTimePattern = %ld", m_lPatternId);
pPatternStepTable->Open(CRecordset::dynaset, strQuery, CRecordset::executeDirect);
pPatternStepTable->Close();
Since these classes wrap the ODBC APIs, you also have the flexibility of making native calls
like this:
HSTMT hStmt;
::SQLAllocHandle(SQL_HANDLE_STMT, pDB->m_hdbc, &hStmt);
nSqlRet = ::SQLExecDirect(hStmt, (SQLTCHAR *)(const TCHAR *)strQuery, _tcslen(strQuery));
...etc.
|
|
|
|
|
Turns out that CDatabase has an ExecuteSQL(LPCSTR) method that handles the CQueryDef functionality, so I'm covered there.
I'd already looked at the SetBookmark help. The reason I was using the bookmark code was due to the fact that after you call CDaoRecordset::Update() the object no longer pointed to the record just updated. In other words,
// member variable in a given class
CRecordset m_rs;
m_rs.AddNew();
m_rs.SetSomeMemberVariables("record 42");
m_rs.Update()
// m_rs no longer points to "record 42"
Using GetLastModifiedBookmark(), I could set the current bookmark to the record just updated. Now I have no way of doing this.
How does CRecordset behave after a call to Update()? If it doesn't point to the record just updated, how do you get it back?
|
|
|
|
|
I'm pretty sure it still points to the record. You'd have to call CRecordset::Edit, make any
column changes and call Update again to edit the record after using AddNew/Update. If you close
the query, though, you'll have to use a bookmark or some other way to obtain the record again.
Note that on CRecordset::Open, you'll want to use the appropriate option flags (CRecordset::appendOnly
to just add new records, CRecordset::readOnly if you are just going to read records, etc.).
Using CRecordset::none allows you to edit, addnew, and delete records.
|
|
|
|