|
Hey Guys
Does anybody know how to declare your own size variables in c++ for instance i want to make my own variable that is say 4bits or is 5 bytes big.
I guess this would have to be done in assembler.
Cheers
Peter
|
|
|
|
|
|
I'm not sure I fully understand the question at hand.
However you can create custom data types using structs or classes.
struct CustomType{
char theBytes[5]; //5 byte data type
unsigned theBits : 2; //*** : *** allows bit control
};
with the above code it's now possible to create an instance of your custom data type which holds 5 bytes instead of the built-in generic char, int, long, etc...
CustomType newType; //new datatype
unsigned char Type; //built-in datatype
Hope this helps
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
I have an NT service program that seems to get a lot of access violations. In trying to track them down, I've found all sorts of odd things going on. Here is one of them.
In this example this piece of code is called from a OnTimer callback routine. The timer was started from the COM object that the ATL wizard makes when you ask it to build a serice.
e.g. Service -> IEntry.StartProcess -> SetTimer
LONG OdysseyLog::GetRegStrValue(const TCHAR szSubKey[], const TCHAR szValueName[], TCHAR *pszReturnVal[], unsigned int *uiLen){ LONG lRes = ERROR_SUCCESS; DWORD dwType; DWORD dwSize; HKEY hKey; try { dwType = REG_SZ; lRes = RegOpenKeyEx( HKEY_LOCAL_MACHINE, szSubKey, 0, KEY_READ, &hKey); if (lRes != ERROR_SUCCESS) { throw true; }
I get an Access Violation from the throw statement! How can that happen? The access violation is in Kernel32.dll at 0xE06D7363. running NT 4.0 with latest SPs (don't know the number, but the admin guys assure me this server is up to date).
Thanks for the help,
Bill
|
|
|
|
|
I have been using Win32 API for four years now and I never came across this function before. I thought I would bring it to every one else's attention.
MessageBoxIndirect creates a standard style MessageBox but will use a custom icon if specified and will load strings from a resource string table! (Great for international applications.) According to MSDN it is available on Windows 95 and up.
|
|
|
|
|
According to Smart Computing in Fall 2000 the MSDN listed 1949 API's, I wonder how many ship with XP. Nonetheless 2000 of anything is alot to learn, nevermind complex API functions.
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
Hi all,
I need to make my program respond to a hotkey, and I have written a DLL that installs a global keyboard hook to send a message back to my main window.
The only problem is I only get the keyboard messages when my app has focus.
Does anyone know why I don't see keyboard events for all threads? }
Thanks in advance for any help!
Here's some code from the DLL:
// Keyboard hook install
PSKEYBD_API BOOL CreateKeybdHook(UINT nCallbackMessage, HWND hwndWindow, DWORD dwVirtKeyCode, DWORD dwKeyInfo) {
hwndKBHookWindow = hwndWindow;
dwKBHookCallbackMessage = nCallbackMessage;
dwKBHookHotkey = dwVirtKeyCode;
// Install as global hook (last param is 0)
SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)KeyboardHookProc, (HINSTANCE)hInstance, 0);
return TRUE;
}
// The keyboard hook function
LRESULT CALLBACK KeyboardHookProc(int code, WPARAM wParam, LPARAM lParam) {
// Make sure this is a WM_KEYDOWN and not a key repeat
if (code == HC_ACTION && !(lParam & 0x80000000) && !(lParam & 0x40000000)) {
// Was this our hotkey?
if (wParam == dwKBHookHotkey) {
::PostMessage(hwndKBHookWindow, dwKBHookCallbackMessage, WPARAM(0), LPARAM(0));
//MessageBeep(MB_ICONINFORMATION);
}
}
return CallNextHookEx(hHook, code, wParam, lParam);
}
|
|
|
|
|
I used a keyboard hook a while but cannot remember the details. I will check my code when I get home (at work right now) and see if I can help.
In the mean time, you may want to look at RegisterHotKey. As I understand from the documentation, Windows will send a WM_HOTKEY message to the HWND specified when RegisterHotKey was called when your key combination is pressed. (I have never tried this myself so I don't know if it will do what you are need it to do.)
|
|
|
|
|
Hi Henry,
I fixed my problem.
In my DLL I forgot to put:
#pragma comment(linker, "/section:.XDATA,rws")
After my shared data segment definition.
Thanks a lot for your reply!
|
|
|
|
|
I need to filter the records a user will be able to see based on an int field. I set the m_strFilter variable of the recordset belonging to the recordview.
<br />
m_pSet->m_strFilter = "[Active] = 1";<br />
However, scrolling through the records from the recordview still presents me with all records, including ones where Active != 1. So I thought perhaps I should call requery to make it notice my filter change. Instead, now scrolling through the records presents me with endless "field can't be updated" errors.
I have the feeling I just don't understand the DAO framework as of yet. Any suggestions? TIA.
Simon
Hey, it looks like you're writing a letter!
Sonork ID 100.10024
|
|
|
|
|
Try to open de Table with a sentences SQL
strQry.Format("Select * from MyTable where Active = %d", 1);
Regards...
Is Friday!!! And Party!!!
My Big Question is: Where is Buffy???
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
The problem is that I have a checkbox on the form that will enable the user to skip records where Active = 0. Opening and closing the recordset makes funny things happen.
Simon
Nobody does chicken like MFC
Sonork ID 100.10024
|
|
|
|
|
Okay, Ni problem: Use Find, FindFirst, FindNext functions, Depending if the user selected the CheckBox...
First you need to Open the Recordset, in that mode you have access to ALL records, Then if the user selected Active=1 Use the Find function for Browse over every record that has the condition, if the user selected Active=0 Use The Find function again.... But if you want can browse all records using movefirst, movenext, etc....
Regards!!!
Is Friday!!! And Party!!!
I have a Big Question: Where is Buffy!!!
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Okay, Ni problem: Use Find, FindFirst, FindNext functions, Depending if the user selected the CheckBox...
First you need to Open the Recordset, in that mode you have access to ALL records, Then if the user selected Active=1 Use the Find function for Browse over every record that has the condition, if the user selected Active=0 Use The Find function again.... But if you want can browse all records using movefirst, movenext, etc....
Regards!!!
Is Friday!!! And Party!!!
I have a Big Question: Where is Buffy???
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Ok Carlos, here's my current thinking;
BOOL CFilmMaintView::OnMove(UINT nIDMoveCommand)
{
if(m_ctrActiveOnly.GetCheck() == 1) {
CString sFilter = "[Active] = 1";
switch(nIDMoveCommand)
{
case ID_RECORD_NEXT : m_pSet->FindNext(sFilter); break;
case ID_RECORD_PREV : m_pSet->FindPrev(sFilter); break;
case ID_RECORD_FIRST : m_pSet->FindFirst(sFilter); break;
case ID_RECORD_LAST : m_pSet->FindLast(sFilter); break;
}
} else
CDaoRecordView::OnMove(nIDMoveCommand);
return true;
}
My problem is that the record view is not updated with the recordset. It appears as though the recordset is moving, but the record view is not updating the fields to reflect the recordset. Messing with the view's recordset doesn't automatically update the view. If I call OnMove() , the view goes out of sinc with the set and I get "can't update" errors. Any ideas?
Simon
Nobody does chicken like MFC
Sonork ID 100.10024
|
|
|
|
|
Hi!
How to put file into the clipboard (Copy, Cut) just like it is implemented in Windows Explorer? I can only find Paste implementation which uses DragQueryFile and COleDataObject.
Mukkie
|
|
|
|
|
Build a DROPFILES struct and store it in the clipboard as the CF_HDROP format. (An HDROP is just a DROPFILES*)
--Mike--
My really out-of-date homepage
He who laughs last, didn't get the punchline and is just laughing so he won't look silly.
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I have an application. When the user clicks save, then
I put all the information into five (5) separate txt files.
It's easy to do.
However, how can I save the file as one file with a specific
type? I can append all the information from each file onto
the new file (and separate it with some blank spaces and other
notes), but let's say I save it as a info.dyl (I just made that
up). Windows explorer doesn't recognize the dyl file type.
How can I make it this new file type be recognizable and have
it's own icon? Can I create any new file type?
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Hi Danielle ,
You could save your file in xml format, a lot of companies are currently doing this ...
Or you could go to Explorer shift-right click, choose "open with ..." then
choose your executable , this association will be saved in the registry,
and in your application catch the command line parameter's , in case of MFC CComandLine , or you could program a shell extension (Michael Dunn excellent articles ).
Hope this helps,
Cheers,
Joao Vaz
|
|
|
|
|
You can store your data however you like, but it sounds like OLE structured storage would be good for you, since you could then keep all 5 sets of data separate, yet all in the same disk file.
As for making an association with .dyl files, you just have to create the right reg keys under HKEY_CLASSES_ROOT. Look at HKCR\.txt and HKCR\txtfile to see how it's done for .txt files.
--Mike--
My really out-of-date homepage
He who laughs last, didn't get the punchline and is just laughing so he won't look silly.
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
HKEY_CLASS_ROOT\.dyl
As default value save "dylfile"
HKEY_CLASS_ROOT\dylfile\Shell\open\command
As default value save Your application Path. For Example "C:\MyApps\dlyApp.exe %1"
Regards....
Is Friday!!! and Party!!!
My big question is: Where is Buffy????
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hi Guys,
I've been wondering this for a while. What is the difference between retail symbols and checked symbols for Windows XP? Which one would be most useful for debugging? And, is there any performance difference when installing either of them?
http://www.microsoft.com/ddk/debugging/symbols.asp
Frank
|
|
|
|
|
Don't get the checked symbols unless you are running a checked build of the OS.
--Mike--
My really out-of-date homepage
He who laughs last, didn't get the punchline and is just laughing so he won't look silly.
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
How can i code a dialog to run and call OnInitDialog() and immediately close it again (possibly invisible) from another parent dialog?
Kuniva
--------------------------------------------
God gave man a penis and a brain but not enough blood to make both of 'em work at the same time.
|
|
|
|
|
I think you want to create a modeless dialog
call CDialog::Create() instead of CDialog::Modal()
remove visible flag in the dialog editor.
- God bless the World
|
|
|
|