-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(win32-api): gdi32.CreateCompatibleDC()
- Loading branch information
1 parent
2cdb74c
commit 956587d
Showing
8 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* eslint-disable id-length */ | ||
import * as M from 'win32-def' | ||
import * as W from 'win32-def/common.def' | ||
|
||
|
||
export interface Win32Fns { | ||
|
||
/** | ||
* @link https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createcompatibledc | ||
*/ | ||
CreateCompatibleDC: (hdc: M.HDC) => M.HDC | ||
} | ||
|
||
|
||
export const apiDef: M.DllFuncs<Win32Fns> = { | ||
|
||
CreateCompatibleDC: [W.HDC, [W.HDC] ], | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { FnName, LoadSettings } from 'win32-def' | ||
|
||
import { loadAsync as hload } from '../helper.js' | ||
import { DllNames } from '../types.js' | ||
|
||
import { apiDef, Win32Fns } from './api.js' | ||
|
||
|
||
export { apiDef } | ||
export { Win32Fns } | ||
export const dllName = DllNames.gdi32 | ||
export const load = ( | ||
fns?: FnName[], | ||
settings?: LoadSettings, | ||
) => hload<Win32Fns>(dllName, apiDef, fns, settings) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ExpandFnModel, FnName, LoadSettings } from 'win32-def' | ||
|
||
import { load as hload } from '../helper.js' | ||
import { DllNames } from '../types.js' | ||
|
||
import { apiDef, Win32Fns } from './api.js' | ||
|
||
|
||
export { apiDef } | ||
export { Win32Fns } | ||
export const dllName = DllNames.gdi32 | ||
/** | ||
* @deprecated use promise instead | ||
* ```ts | ||
* import { User32 } from 'win32-api/promise' | ||
* const user32 = User32.load() | ||
* const hWnd = await user32.FindWindowExW(...) | ||
* ``` | ||
*/ | ||
export const load = ( | ||
fns?: FnName[], | ||
settings?: LoadSettings, | ||
) => hload<ExpandFnModel<Win32Fns>>(dllName, apiDef, fns, settings) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/win32-api/test/gdi32/201.CreateCompatibleDC.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import assert from 'node:assert/strict' | ||
|
||
import { fileShortPath } from '@waiting/shared-core' | ||
import ref from 'ref-napi' | ||
import { sleep } from 'zx' | ||
|
||
import * as CS from '../../src/index.consts.js' | ||
import { | ||
DModel as M, | ||
DTypes as W, | ||
DStruct as DS, | ||
StructFactory, | ||
} from '../../src/index.js' | ||
import { gdi32 } from '../helper.js' | ||
|
||
|
||
describe(fileShortPath(import.meta.url), () => { | ||
|
||
describe('Should CreateCompatibleDC() work', () => { | ||
it('normal', async () => { | ||
const hdc = await gdi32.CreateCompatibleDC(0) | ||
console.log({ hdc }) | ||
assert(hdc) | ||
}) | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters